Repository navigation
Conversation
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| SearchPagedResponse, | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. GoogleAdsServiceClient.search() returns a SearchPager:
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchPagedResponse, | |
| GoogleAdsRow, | |
| ) | |
| from google.ads.googleads.v26.services.services.google_ads_service.pagers import ( | |
| SearchPager, | |
| ) | |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| GoogleAdsRow, | |
| ) |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| SearchGoogleAdsRequest, | ||
| SearchPagedResponse, | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| SearchPagedResponse, | |
| GoogleAdsRow, | |
| ) | |
| from google.ads.googleads.v26.services.services.google_ads_service.pagers import ( | |
| SearchPager, | |
| ) | |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| GoogleAdsRow, | |
| ) |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| SearchGoogleAdsRequest, | ||
| SearchPagedResponse, | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| SearchPagedResponse, | |
| GoogleAdsRow, | |
| ) | |
| from google.ads.googleads.v26.services.services.google_ads_service.pagers import ( | |
| SearchPager, | |
| ) | |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| GoogleAdsRow, | |
| ) |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| SearchPagedResponse, | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead.
Also note: MutateCustomerClientLinkResponse (imported on line 30) has a singular .result field in v26 rather than .results, so response.results[0].resource_name on line 86 will raise an AttributeError (should be response.result.resource_name).
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| SearchGoogleAdsRequest, | ||
| SearchPagedResponse, | ||
| ) |
There was a problem hiding this comment.
SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| SearchPagedResponse, | |
| ) | |
| from google.ads.googleads.v26.services.services.google_ads_service.pagers import ( | |
| SearchPager, | |
| ) | |
| from google.ads.googleads.v26.services.types.google_ads_service import ( | |
| SearchGoogleAdsRequest, | |
| ) |
| GoogleAdsServiceClient, | ||
| ) | ||
| from google.ads.googleads.v24.services.types import * | ||
| from google.ads.googleads.v26.services.types import * |
There was a problem hiding this comment.
Avoid wildcard imports (import *) per the Google Python Style Guide, especially on services.types which loads hundreds of protobuf classes into the module namespace. Explicitly import the operation/response types used in this example instead.
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| MutateGoogleAdsResponse, | ||
| MutateOperation, | ||
| MutateOperationResponse, |
There was a problem hiding this comment.
MutateOperationResponse is imported here but unused in this file.
|
|
||
| from google.protobuf import field_mask_pb2 | ||
| from google.ads.googleads.v24.resources.types import youtube_video_upload | ||
| from google.ads.googleads.v26.resources.types import youtube_video_upload |
There was a problem hiding this comment.
youtube_video_upload (line 52), GoogleAdsRow (line 35), and UpdateYouTubeVideoUploadRequest / UpdateYouTubeVideoUploadResponse / RemoveYouTubeVideoUploadRequest / RemoveYouTubeVideoUploadResponse (lines 45–48) are unused in this file and can be removed.
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
GoogleAdsRow is imported here but unused in this file.
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| GoogleAdsRow, | ||
| ) |
There was a problem hiding this comment.
GoogleAdsRow is imported here but unused in this file.
- Replace nonexistent SearchPagedResponse with SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers in account_management examples - Fix MutateCustomerClientLinkResponse.result access in link_manager_to_client.py - Move InsightsAudienceAttributeGroup import to common.types in generate_audience_insights.py - Fix AdTextAsset import path in validate_ad.py - Migrate hotel bid modifier fields to v26 generalized booking criteria in add_hotel_ad_group_bid_modifiers.py and get_ad_group_bid_modifiers.py - Fix type annotations in add_call.py (CallAsset), detect_and_apply_recommendations.py (ApplyRecommendationResponse), and add_shopping_product_listing_group_tree.py (MutateAdGroupCriteriaResponse) - Replace wildcard import in add_app_campaign.py with explicit imports - Remove unused imports in add_performance_max_campaign.py, async_search.py, and async_search_stream.py
9e5387f to
152345c
Compare
| # GoogleAdsClient will read the google-ads.yaml configuration file in the | ||
| # home directory if none is specified. | ||
| googleads_client = GoogleAdsClient.load_from_storage(version="v24") | ||
| googleads_client = GoogleAdsClient.load_from_storage(version="v26") |
There was a problem hiding this comment.
Switching to v26 breaks line 159 (request.cookie_frequency_cap = 0): cookie_frequency_cap was removed from GenerateReachForecastRequest in v26 (replaced by cookie_frequency_cap_setting), so this will raise an AttributeError at runtime.
- Removing line 159 leaves the frequency cap uncapped by default, or it can be migrated to
request.cookie_frequency_cap_setting.
| AdTextAsset, | ||
| ) | ||
| from google.ads.googleads.v24.errors.types.policy_finding_error import ( | ||
| from google.ads.googleads.v26.errors.types.policy_finding_error import ( |
There was a problem hiding this comment.
Line 169 references client.enums.PolicyFindingErrorEnum.POLICY_FINDING, which raises AttributeError at runtime because PolicyFindingErrorEnum lives under errors.types rather than enums.types.
- Since
PolicyFindingErrorEnumis already imported here, line 169 can usePolicyFindingErrorEnum.POLICY_FINDINGdirectly. - Also on line 183,
policy_finding_detailsis annotated asPolicyFindingErrorEnuminstead ofPolicyFindingDetails(fromgoogle.ads.googleads.v26.errors.types.errors).
| from google.ads.googleads.errors import GoogleAdsException | ||
| from google.ads.googleads.v24.common.types.bidding import TargetSpend | ||
| from google.ads.googleads.v24.resources.types.accessible_bidding_strategy import ( | ||
| from google.ads.googleads.v26.common.types.bidding import TargetSpend |
There was a problem hiding this comment.
TargetSpend is imported here but unused in this file and can be removed.
| ReachPlanServiceClient, | ||
| ) | ||
| from google.ads.googleads.v24.services.types.reach_plan_service import ( | ||
| from google.ads.googleads.v26.services.types.reach_plan_service import ( |
There was a problem hiding this comment.
Two v26 breaking changes in request_reach_curve will raise AttributeError at runtime:
- Line 159:
request.cookie_frequency_capwas removed fromGenerateReachForecastRequestinv26(replaced bycookie_frequency_cap_setting). - Line 163:
request.targeting.plannable_location_idwas removed fromTargetingand replaced by the repeatedplannable_location_idsfield (e.g.,request.targeting.plannable_location_ids.append(location_id)).
| ) | ||
| from google.ads.googleads.v24.common.types.criteria import ( | ||
| from google.ads.googleads.v26.common.types.criteria import ( | ||
| AddressInfo, |
There was a problem hiding this comment.
AddressInfo (from v26.common.types.criteria) is imported here to annotate address_info: AddressInfo = user_identifier.address_info on line 459, but user_identifier.address_info is actually OfflineUserAddressInfo (from google.ads.googleads.v26.common.types.offline_user_data). AddressInfo does not define hashed_first_name or hashed_last_name.
| ) | ||
| from google.ads.googleads.v24.errors.types.policy_finding_error import ( | ||
| from google.ads.googleads.v26.errors.types.policy_finding_error import ( | ||
| PolicyFindingErrorEnum, |
There was a problem hiding this comment.
PolicyFindingErrorEnum is imported here to annotate policy_finding_details: PolicyFindingErrorEnum = error.details.policy_finding_details on line 183, which is actually PolicyFindingDetails (from google.ads.googleads.v26.errors.types.errors).
| from google.ads.googleads.v26.services.types.google_ads_service import ( | ||
| GoogleAdsRow, | ||
| SearchGoogleAdsRequest, | ||
| SearchGoogleAdsResponse, |
There was a problem hiding this comment.
ga_service.search(...) on line 70 returns a SearchPager (from google.ads.googleads.v26.services.services.google_ads_service.pagers), not SearchGoogleAdsResponse. Updating the import and annotation to SearchPager matches the account_management examples in this PR.
The same SearchGoogleAdsResponse annotation on .search(...) also appears in find_and_remove_criteria_from_shared_set.py, get_responsive_search_ads.py, get_all_disapproved_ads.py, evaluate_and_update_experiment.py, set_up_remarketing.py, update_audience_target_restriction.py, add_performance_max_product_listing_group_tree.py, add_performance_max_retail_campaign.py, and add_shopping_product_listing_group_tree.py.
No description provided.