Skip to content
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

Mypy Support? #57

Open
ahawker opened this issue Sep 2, 2020 · 3 comments · May be fixed by #59
Open

Mypy Support? #57

ahawker opened this issue Sep 2, 2020 · 3 comments · May be fixed by #59

Comments

@ahawker
Copy link

ahawker commented Sep 2, 2020

I've got a WIP implementation of mypy type stubs for this package in adbpy/transports@43a26a8.

I haven't finished them yet but I'm opening this issue to get the conversation going. Is this something you would be interested in taking upstream once complete? Otherwise, I'll look into breaking them out into a separate stubs-only package.

@vpelletier
Copy link
Owner

I am interested in taking these here, yes.

I am not sure whether I would prefer separate .pyi files or comment-style annotations though: I would tend to prefer the type declarations to be immediately visible while editing the code. But this means doing (part of) the work 3 times: the work you are already doing (where stubs make perfect sense), then converting to comments when upstreaming, then eventually converting them to py3 annotations once 2.7 support goes away (I believe I should still keep it around some more).

I am not familiar with mypy, though, so I am not used to its best-practices, or maybe there is some tool to convert between annotation types.

@ahawker
Copy link
Author

ahawker commented Sep 3, 2020

I know https://github.com/ilevkivskyi/com2ann exists for converting py2 comment types to py3 but I am unaware of a tool that does the reverse.

For reference, support for comment based types is oulined in https://mypy.readthedocs.io/en/stable/python2.html. I would have to do some research but I am currently unaware of how we would use comment based types for all of the dynamic exports defined in __all__, e.g. converting LIBUSB_CLASS_PER_INTERFACE to CLASS_PER_INTERFACE and dynamically creating the USBErrorXYZ exceptions classes.

In any case, I'll continue work to finish up the stubs as best I can and we can go from there.

@ahawker ahawker linked a pull request Sep 8, 2020 that will close this issue
@mcuee
Copy link

mcuee commented Sep 9, 2021

Maybe it is time to drop Python 2.7 support now (as well as Python 3.5 or older).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants