-
Notifications
You must be signed in to change notification settings - Fork 102
Replace validate_stubs
scripts with stubtest
#371
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
Replace validate_stubs
scripts with stubtest
#371
Conversation
c700e37
to
dbf819b
Compare
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
@debonte If you prefer, I can split off the changes to test across different Python versions |
I think I'm through all the issues anyway ^^ |
…into Replace-validate_stubs-scripts-with-stubtest
As this PR grows, I ended up splitting it off after all: #375 |
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
…into Replace-validate_stubs-scripts-with-stubtest
# follow_untyped_imports = true will cause stubtest to run mypy on the source | ||
# So disable it for partial stubs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't feel like optimal behaviour for stubtest. I'll raise an issue upstream.
# This code is never run in runtime, but it's here for type checking. | ||
# Type checkers fail to understand that the `set_{method}_request` | ||
# methods are dynamically generated, and they complain that they are | ||
# not defined. We define them here to make type checkers happy. | ||
# During type checking analyzers assume this to be True. | ||
# The following list of defined methods mirrors the list of methods | ||
# in SIMPLE_METHODS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the message from the source here to explain why these methods are there despite not existing at runtime.
…//github.com/Avasam/python-type-stubs into Replace-validate_stubs-scripts-with-stubtest
validate_stubs.py
doesn't really work in its current state. I'm sure there's plenty more issues, but mainly it tries to import stub files and stubs-only symbols.Stubtest is as actively maintained as mypy and is a core tool to typeshed's own testing to validate that stubs match the content of implementation.
https://mypy.readthedocs.io/en/stable/stubtest.html
Updated.github/workflows/test.yml
to test both oldest and newest python version. This will help uncover issues likenumpy.distutils
not being available on Python 3.12+utils/validate_stubs.py
in favor oftests/run_stubtest.py
Whilst all other tools help you ensure your stubs are valid, sane, or simply follow modern standards. This is actually the best metric you'll have to see how close the stubs are to actual implementation (or rather, how much they've diverged over time)