henribru / google-ads-stubs Goto Github PK
View Code? Open in Web Editor NEWType stubs for the Google Ads API Client Library for Python
Home Page: https://pypi.org/project/google-ads-stubs/
License: Apache License 2.0
Type stubs for the Google Ads API Client Library for Python
Home Page: https://pypi.org/project/google-ads-stubs/
License: Apache License 2.0
Will need to advice people to use --namespace-packages
for Mypy.
Hi!
I have been using this project for a while and I would like to know the best way I can collaborate or help you.
Thank you in advance!
v16 of Google Ads API was released a few weeks back and exposes a new set of modules, .v16
, for most types of the google-ads
package. Here's the release notes: https://github.com/googleads/google-ads-python/releases/tag/23.1.0
Importing from the new v16
modules results in mypy complaining, even with this stubs library present:
tap_googleads/streams/base.py:5: error: Skipping analyzing "google.ads.googleads.v16": module is installed, but missing library stubs or py.typed marker [import-untyped]
No huge changes seem present in the new API version, but new users will likely use .v16
in their code and will be confused by this library not working out of the box.
Thanks for the great work! This is a great resource to run in tandem with mypy to minimize "dumb" bugs in production.
All the message classes currently inherit __contains__
from proto.Message
. The annotation for this accepts any string: https://github.com/henribru/proto-plus-stubs/blob/master/proto-stubs/message.pyi#L58
But at runtime only the strings for actual fields are allowed. "foo" in GoogleAdsRow()
will raise an exception. It could be useful to generate custom __contains__
annotations for each message.
Hello, me again.
These stubs have been awesome. Thanks again.
A little while ago I noticed PyCharm complains about missing imports in other, non ads, google packages. Guessing due to their namespacing pattern of having completely separate pypi packages install in the same google/
folder.
As a workaround, I've just been uninstalling these stubs when doing non ads related work. Which works no problem, so this isn't anything important.
I was just curious if you knew any workarounds to make these coexist.
Unfortunately this involves throwing away almost all of the stubs and redoing them as v10 completely changed how protobuf objects are represented ... Can't use mypy-protobuf either, would have to write a custom stub generator for proto-plus-python.
Technically the existing work could be used for the use_proto_plus=False
case, but I suspect most people will use use_proto_plus=True
.
Following the first issue of this repository #1, I've discovered that my import failures on Pycharm and VSC where coming from the editor themselves and not this package.
For reference, here are the opened tickets on the subject for PyCharm:
I was unable to locate similar issues for Pylance. If someone have it working in Visual, please let me know :)
As it seems unlikely that it will be fixed in the near future, would you accept a PR with a note on the IDEs current limitation and non implementation of PEP-561 in the 'Caveats' section of the package README ? It seems to me like a major pain point for users of this package, and something I would like to know before using it.
Thanks !
Hi,
I'd be really to stoked to have typechecking for google-ads
so interested in getting this working.
Using versions:
google-ads==5.1.0
google-ads-stubs==3.1.0
Currently having the following issues:
namespace_packages
With config:
[mypy]
namespace_packages = True
getting errors like
some/file.py:2: error: Module 'google.cloud' has no attribute 'bigquery' [attr-defined]
some/file2.py:9: error: Module 'google.cloud' has no attribute 'storage' [attr-defined]
Making namespace_packages = False
avoids these errors.
With an example file like:
from google.ads import google_ads
def get_client() -> google_ads.client.GoogleAdsClient:
"""Get an authenticated Google Ads client."""
... [pulling credentials] ...
return google_ads.client.GoogleAdsClient.load_from_dict(credentials)
gives error:
example/file.py:2: error: Name 'google_ads.client.GoogleAdsClient' is not defined [name-defined]
example/file.py:5 error: Module has no attribute "client" [attr-defined]
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.