-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for PEP 561 #6
Comments
Thanks for the interest! I've personally never used mypy or another type checker, but my first intuition for this package was to use .pyi files. However, I wasn't able to get it working. I think it's related to the package structure of I've had some success using .pyi files to type methods that are created at runtime in one of my other projects All of that said, I'd MUCH prefer to get stub files working than to have these mock classes. It's at best a workaround and at worst a hack (probably closer to a hack, but still a pretty convenient one). In a perfect world, this would just be a part of typeshed. I could probably devote some time on the weekends to experimenting with it, and if you want to give it shot, you're more than welcome to! Only contributor guideline is any new code should adhere to the PEP8 (obviously that constraint doesn't apply to the |
Hmmm, actually..... As a quick fix for static type checking, do you think just adding .pyi files for the existing mock classes would work? Something like this:
What are your thoughts on this? Like I said, I haven't ever used mypy. One caveat I can see here is that you're not actually instantiating the mock objects. Not sure how that would play with mypy. |
@cowboygneox submitted pull request #9 which demonstrates how support for mypy would work. After a little bit of experimentation, it looks like this should play well with IDEs as well. Supporting mypy with the current build scripts would just take a new build configuration. It would look something like this: services: all
with_docs: true
with_clients: true
with_service_resources: true
with_paginators: true
with_waiters: true
package_name: boto3-stubs
module_name: boto3-stubs
version: 0.3.1
readme: "../README.md"
license: "../LICENSE That should be good enough for this too work with mypy. There do appear to be some problems with IDEs, though. After checking out the pull request and install the package, I made the following script: import boto3
from boto3 import sts
sts_client: sts.Client = boto3.client(service_name='sts') PyCharm recognizes that Also, I just want to say that I feel pretty dumb for not looking up PEP 561 when this issue was opened. I think I just assume it was PEP 484. This all should have been done back in May. |
@alliefitter I recommend that we get your existing stubs to work as a For now, if you want to be mypy compliant with what you've already produced, just do the following:
|
And just to be super clear:
^ That is MyPy compliant. |
Welp, @JoeyBG, @cowboygneox, @hevy-CC4477, I've got some good news for ya'll. |
Does this mean you won't move forward with #9 changes ? |
I agree that we should make some decision on this. I don't see why we can't merge it and then just bail if AWS' version is better. This could be made available pretty quickly if we decide to execute. |
Sorry about the long silence. Haven't had much time for side projects over the last few months. As an explanation of my reasoning for not going forward with the
In the boto3 issue I tagged above, they didn't give me permission to do so. However, someone else has forked the repo and released a |
Hi!
This looks great. Currently, there seems to be no way to use this properly with a type checker (such as mypy) to validate code.
From their documentation (https://mypy.readthedocs.io/en/latest/installed_packages.html and the linked PEP) it seems that there is a couple options available:
Not sure how 2) would play with IDEs and stuff...
If it's something that you would be willing to add support for, I could be interested in helping out a bit.
The text was updated successfully, but these errors were encountered: