Add initial mypy support
Status: Ready for review Issue: Fixes #57
If merged, this PR adds initial support for mypy.
- Type stubs,
.pyifiles have been added for the package interface__init__.pyandlibusb1.pymodule. - The
_version.pymodule and tests are currently excluded from checks (seemypy.ini). They're skipped now since they're "internal" but can easily be added to type checks in the future.
I did the best I could with the type definitions for functions that I'm not using in https://github.com/adbpy/transports but there are potentially some mistakes/inconsistencies. These should be relatively easily to "whack-o-mole" as they come up (or during code review for someone that knows the codebase better).
Testing
The stubs should pass normal and strict checks.
hawker@mbp:~/src/github.com/ahawker/python-libusb1|master⚡
⇒ mypy usb1 && mypy --strict usb1
Success: no issues found in 4 source files
Success: no issues found in 4 source files
There is also a new Travis CI job for validating the mypy type hints on py36.
I also ran them against all the code in the examples/ directory. All types exported from the package appear correct in there, with the only strict errors being the fact that the examples themselves aren't typed.
@vpelletier Thank you for taking the the time to do an in-depth review & feedback! Life's gotten a bit busy so it'll be a little slower to tidy this up but just letting you know I haven't forgotten.
You're welcome. There is no hurry, on my side it's also getting pretty busy, and will probably remain so for about a month.