-
Notifications
You must be signed in to change notification settings - Fork 505
Add type hints to files in examples/advanced_operations #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces type hints to several files within the examples/advanced_operations directory for Google Ads API v19. The following files have been updated: - examples/advanced_operations/add_ad_customizer.py - examples/advanced_operations/add_ad_group_bid_modifier.py - examples/advanced_operations/add_app_campaign.py - examples/advanced_operations/add_bidding_data_exclusion.py - examples/advanced_operations/add_bidding_seasonality_adjustment.py - examples/advanced_operations/add_call_ad.py - examples/advanced_operations/add_demand_gen_campaign.py - examples/advanced_operations/add_display_upload_ad.py Changes include adding type hints for function arguments, return values, and relevant local variables. Necessary types were imported from the `typing` module and `google.ads.googleads.client`. In `add_display_upload_ad.py`, an `argparse` type for `ad_group_id` was corrected from `int` to `str` to match its usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Minor comment.
@@ -162,15 +174,17 @@ def create_display_upload_ad_group_ad( | |||
parser.add_argument( | |||
"-a", | |||
"--ad_group_id", | |||
type=int, | |||
type=str, # Changed to str to match main function signature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is no longer necessary.
@@ -73,22 +76,22 @@ def create_text_customizer_attribute(client, customer_id, customizer_name): | |||
Returns: | |||
a resource name for a text customizer attribute. | |||
""" | |||
customizer_attribute_service = client.get_service( | |||
customizer_attribute_service: Any = client.get_service( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can actually specify the type here, it's google.ads.googleads.v20.services.services.customizer_attribute_service.CustomizerAttributeService
We'd need to import it directly.
Looks like this is the case for a few of the API-specific types below too. If we are specific about these types, then there's a slight maintenance overhead as we'll need to ensure the import paths match the API version. What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to import them to use annotations. Would existing types change import paths with any regularity.
This sounds like a verification task that we could hand off to Jules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure that 99.9% of the time the only change to import paths will be for new version releases, which could easily be handled by Jules or with a basic sed
command.
operation = client.get_type("CustomizerAttributeOperation") | ||
price_attribute = operation.create | ||
operation: Any = client.get_type("CustomizerAttributeOperation") | ||
price_attribute: Any = operation.create |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the type google.ads.googleads.v20.resources.types.CustomizerAttribute
Even though its more overheard, I think it kind of makes sense to specify this. Do you think Jules would be able to figure that out?
This commit introduces type hints to several files within the examples/advanced_operations directory for Google Ads API v19.
The following files have been updated:
Changes include adding type hints for function arguments, return values, and relevant local variables. Necessary types were imported from the
typing
module andgoogle.ads.googleads.client
.In
add_display_upload_ad.py
, anargparse
type forad_group_id
was corrected fromint
tostr
to match its usage.