-
-
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
[WIP] Begin implementing PEP 561 checking #4278
Conversation
This is the initial work to add packages that opt into type checking via PEP 561.
@@ -792,6 +792,21 @@ def find() -> Optional[str]: | |||
dir = os.path.normpath(os.path.join(pathitem, dir_chain)) | |||
if os.path.isdir(dir): | |||
dirs.append(dir) | |||
try: | |||
user_dir = site.getusersitepackages() |
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.
Doesn't this use the site packages of the mypy installation, not that of the code being typechecked?
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.
Yes I need to add that. Thanks for the reminder!
I think we should suppress errors in these packages, although I haven't thought deeply about the exact semantics required. The general reasoning is that third-party packages aren't code the user controls. If I use mypy with |
Also, I don't think it needs to be behind a flag. |
Namespace package (PEP 420) support should probably wait until it is generally supported in mypy (see #4277), so I removed that from the TODO list for this PR. It seems that Also, ignoring errors in installed packages should be an easy change, so I will implement that. |
I'm afraid I've run out of time, and will it will be a few weeks before I can finish this, which is probably better anyway so that #4277 can be done before I complete this. |
Noticed this working on #4278 :)
Closing in favor of #4403 for simplicity. |
This is the initial work to add checking using packages that opt into type checking via
PEP 561.
TODO:
- [ ] Namespace package support (awaiting #4277)I'm going ahead without this.As of right now, you can install regular packages with types and third party stub packages and they should be picked up.
$MYPYPATH
supersedes both types of packages, and third-party stubs supersede bundled type packages per PEP 561. Errors in installed packages should be ignored.Questions:
- Should this be behind a flag?- Should errors that are ignored in typeshed be ignored for these packages too? I'm not too keen on this, but open to recommendations.