Skip to content

Commit 6d4621b

Browse files
Add type hints to examples/billing
This change adds type annotations and hints to the Python files in the examples/billing directory to improve code readability and maintainability. Type hints were added to function arguments and return values for: - add_account_budget_proposal.py - add_billing_setup.py - get_invoices.py
1 parent 4f350a8 commit 6d4621b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

examples/billing/add_account_budget_proposal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828

2929
# [START add_account_budget_proposal]
30-
def main(client, customer_id, billing_setup_id):
30+
def main(
31+
client: GoogleAdsClient, customer_id: str, billing_setup_id: str
32+
):
3133
account_budget_proposal_service = client.get_service(
3234
"AccountBudgetProposalService"
3335
)

examples/billing/add_billing_setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@
2727
import argparse
2828
from datetime import datetime, timedelta
2929
import sys
30+
from typing import Any, Optional
3031
from uuid import uuid4
3132

3233
from google.ads.googleads.client import GoogleAdsClient
3334
from google.ads.googleads.errors import GoogleAdsException
3435

3536

3637
def main(
37-
client, customer_id, payments_account_id=None, payments_profile_id=None
38+
client: GoogleAdsClient,
39+
customer_id: str,
40+
payments_account_id: Optional[str] = None,
41+
payments_profile_id: Optional[str] = None,
3842
):
3943
"""The main method that creates all necessary entities for the example.
4044
@@ -64,8 +68,11 @@ def main(
6468

6569

6670
def create_billing_setup(
67-
client, customer_id, payments_account_id=None, payments_profile_id=None
68-
):
71+
client: GoogleAdsClient,
72+
customer_id: str,
73+
payments_account_id: Optional[str] = None,
74+
payments_profile_id: Optional[str] = None,
75+
) -> Any:
6976
"""Creates and returns a new billing setup instance.
7077
7178
The new billing setup will have its payment details populated. One of the
@@ -109,7 +116,9 @@ def create_billing_setup(
109116
return billing_setup
110117

111118

112-
def set_billing_setup_date_times(client, customer_id, billing_setup):
119+
def set_billing_setup_date_times(
120+
client: GoogleAdsClient, customer_id: str, billing_setup: Any
121+
):
113122
"""Sets the starting and ending date times for the new billing setup.
114123
115124
Queries the customer's account to see if there are any approved billing

examples/billing/get_invoices.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
import argparse
1919
from datetime import date, timedelta
2020
import sys
21+
from typing import Any, Optional
2122

2223
from google.ads.googleads.client import GoogleAdsClient
2324
from google.ads.googleads.errors import GoogleAdsException
2425

2526

26-
def main(client, customer_id, billing_setup_id):
27+
def main(client: GoogleAdsClient, customer_id: str, billing_setup_id: str):
2728
"""The main method that creates all necessary entities for the example.
2829
2930
Args:
@@ -100,7 +101,7 @@ def main(client, customer_id, billing_setup_id):
100101
# [END get_invoices_1]
101102

102103

103-
def micros_to_currency(micros):
104+
def micros_to_currency(micros: Optional[int]) -> Optional[float]:
104105
return micros / 1000000.0 if micros is not None else None
105106

106107

0 commit comments

Comments
 (0)