-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
stubtest: various improvements #8502
Conversation
hauntsaninja
commented
Mar 6, 2020
•
edited
Loading
edited
- refine verify_signature, fixing a false negative and improving documentation
- ignore "this", another annoying module
- support using regexes in whitelist
- add --ignore-unused-whitelist
- handle name mangling
If runtime takes a keyword-only argument, we now unconditionally check that the stub also does. This leads to good outcomes on typeshed. Also further clarify the comments.
mypy/stubtest.py
Outdated
if not whitelist[w]: | ||
# Don't consider an entry unused if it regex-matches the empty string | ||
# This allows us to whitelist errors that don't manifest at all on some systems | ||
if not whitelist[w] and not whitelist_regexes[w].fullmatch(""): |
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'm not sure I understand what's going on here. Could you give an example of a situation where this would apply?
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.
The motivation here is to create a way to provide a better experience for cases like python/typeshed#3782 where the whitelisted errors don't match up on some user's system.
For instance, on my system running stubtest gives me a number of (unfixable within current type system) errors like termios.B921600 is not present at runtime
, but in CI we don't have any errors from termios
at all. If we added a whitelist entry for termios.[A-Z0-9_]+
, it would complain about an unused whitelist entry in CI. This allows us to add an entry for (termios.[A-Z0-9_]+)?
so things work both on CI and on users' systems, and we can continue to detect unused whitelist entries in general.
This is tested by the unused_missing
part of test_whitelist