-
Notifications
You must be signed in to change notification settings - Fork 156
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
Adding type hints so static analyzers like mypy can work with google.cloud.storage #393
Comments
This would be an amazing feature! Is there any information on the current status? |
Also waiting for this feature as type hints become pretty standard in python nowadays. |
this is pretty ridiculous that this is missing. |
How to Fix ThisI see a number of different approaches the folks at Google could take to resolve this issue. Use Runtime TypesThe most obvious one would be to use an off-the-shelf tool to generate type hints from types observed at runtime: It ought to be relatively trivial to get those runtime types by executing this library's test suite. While these wouldn't be perfect, it'd at least be a starting point. Over time users could contribute fixes to any incorrect/incomplete annotations that were generated initially. Use Docstring TypesBeyond this the code base appears to have relatively thorough docstrings which describe the expected types (e.g. Why This MattersAs mentioned above, type annotations have become the norm in Python. Similar offerings from AWS (types-boto3) and Azure (built-in) already include very thorough type hints. Personally my experience with Google's product offering here has been lessened by the fact that I have to constantly refer to documentation or dig into docstrings as apposed to having type the hints show up and auto-complete in my IDE. One could pretty easily argue that this has a relatively marginal impact, but if I had to guess, that's where cloud platforms are competing since most common product offerings are nearly identical when it comes to features and pricing. Beyond the broader business case, type hints would help the maintainers of this library for the same reasons it would help their users. Additionally, unlike docstrings, the accuracy of type hints can be enforced by a type checker. Without this, ensuring that types in docstring remain up to date with their usages is the responsibility of human code reviewers instead of a machine. |
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Is your feature request related to a problem? Please describe.
Tools like mypy can use type hints to run static analysis on your code to find bugs in incorrect type usage.
Describe the solution you'd like
Mypy requires type hints to be exported by the library, either as part of the library and exported per PEP 484, or as a separate stubs library per PEP 561.
Describe alternatives you've considered
Currently we're ignoring all typing information for this library.
Additional context
The text was updated successfully, but these errors were encountered: