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

stubtest: various improvements #8502

Merged
merged 5 commits into from
Mar 7, 2020
Merged

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Mar 6, 2020

  • 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

hauntsaninja added 3 commits March 6, 2020 12:25
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(""):
Copy link
Member

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?

Copy link
Collaborator Author

@hauntsaninja hauntsaninja Mar 6, 2020

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

@JelleZijlstra JelleZijlstra self-assigned this Mar 6, 2020
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 this pull request may close these issues.

2 participants