-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Silence modules in site-packages and typeshed #5303
Conversation
Huh, this is strange:
I suppose the map messes things up. |
@ethanhs Is this a regression or it was always like this? (There is a chance this is related to a recent overload overhaul.) |
Not sure, I created the repro with https://mypy-play.net, which uses 0.610, I haven't tested it on older versions. |
No, it is a The fix should be straightforward, but if you don't have time, just open an issue about this. |
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 code looks good, but I think we should add a test that installs a PEP 561 with various errors (both import related and non-import-related) to be sure they are all silenced.
@@ -751,15 +751,16 @@ main:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" | |||
main:2: error: Incompatible types in assignment (expression has type "int", variable has type "str") | |||
|
|||
[case testAddFileWhichImportsLibModuleWithErrors] | |||
# flags: --no-silence-site-packages |
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.
Why is this necessary here? Is broken
installed as a PEP 561 package?
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.
Since opening this, I also implemented silencing typeshed, which broken
is simulated as being part of via alt_lib_path
.
mypy/util.py
Outdated
|
||
# backport commonpath for 3.4 | ||
if sys.platform == 'win32': | ||
def commonpath(paths: Sequence[str]) -> str: |
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.
Do we need the general algorithm here? As I understand we essentially only need something like is_sub_path(p1, p2)
. Not that I think it is important, but maybe it will allow to simplify code?
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 was originally hoping to eventually use os.path.commonpath
once we drop support for 3.4, but I think you are right it would be better to do this ourselves. I will change this when I have time later.
I will add some errors to typedpkg to test the functionality. |
OK, thanks! Just note that I would like to cut the release branch tomorrow morning. So it would be better to have the tests by that time. |
Sure thing, I will do that momentarily. |
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.
OK, looks good now!
Fixes #5260 .