Type stubs for google-ads
Project description
Type stubs for the Google Ads API Client Library for Python
This package provides type stubs for the Google Ads API Client Library for Python. It's currently compatible with v16.0.0 of this library. It allows you to type check usage of the library with e.g. mypy and will also improve autocomplete in many editors.
This is in no way affiliated with Google.
Most stubs were created automatically by stubgen, the rest are handwritten or generated by self-made scripts.
If you find incorrect annotations, please create an issue. Contributions for fixes are also welcome.
Installation
$ pip install google-ads-stubs
Caveats
There are some caveats. The primary one is that type inference does not work for the get_type
and get_service
methods of Client
. The workaround is to explicitly state the type. For get_type
you can also instantiate
the object directly.
# Replace this:
campaign_operation = client.get_type('CampaignOperation')
# With this:
from google.ads.googleads.v10 import CampaignOperation
campaign_operation: CampaignOperation = client.get_type('CampaignOperation')
# Or this:
from google.ads.googleads.v10 import CampaignOperation
campaign_operation = CampaignOperation()
# Replace this:
google_ads_service = client.get_service('GoogleAdsService')
# With this:
from google.ads.googleads.v10 import GoogleAdsServiceClient
google_ads_service: GoogleAdsServiceClient = client.get_service('GoogleAdsService')
While it is technically possible to type these methods using a combination of overloading and literal types, this is not included in these stubs. The reason is that it requires about 10,000 overloads, which makes most typecheckers fairly slow.
Another big caveat since v8.0.0 of this package is that the attributes and constructor arguments of the protobuf messages are all typed as Any
instead of their proper types. This is due to google-ads-python
switching from raw protobuf message classes to proto-plus
classes. Better types for these might be introduced in the future. GoogleAdsClient.enums
is also typed as Any
.
Note that if you're using Mypy you need to use the --namespace-packages
option as google
and google.ads
are namespace packages.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for google_ads_stubs-9.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e170779f8fbd3164c597774513add47db2a5298601881dce8f9a5acbd72728d0 |
|
MD5 | a0e6979c4e4c531c0f54c5feca87eab2 |
|
BLAKE2b-256 | 5e60c84b3647bfcfff0ab8d5193a08a5579783411dcf91ed15a31935acaa3155 |