-
-
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
Don't check plugin-generated functions #16524
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[case testDisallowIncompleteDefsAttrsNoAnnotations] | ||
# flags: --disallow-incomplete-defs | ||
[case testDisallowUntypedDefsAttrsNoAnnotations] | ||
# flags: --disallow-untyped-defs |
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.
Would it make sense to also test with --disallow-any-explicit --disallow-any-decorated
, which were used in #16454?
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 is a test for the attrs "regression".
I didn't actually add a regression test for #16454, perhaps I should.
I remember I tried at first, and it was made tricky due --disallow-any-explicit --disallow-any-decorated
flagging errors in the typeshed fixtures. We normally exclude errors in the typeshed from mypy's output, and this should apparently be fixed for test fixtures.
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 easiest workaround might be to just # type: ignore
the fixtures.
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.
How about 33d06cc?
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.
Hmm I'm a little worried about it (see my comment). If there is no other way, it's fine to omit the test cases.
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 follow.
testDisallowUntypedDefsAttrsNoAnnotations
is a "casualty" of this change. I can definitely add --disallow-any-explicit --disallow-any-decorated
to the flags in this test and it still passes. I'm just concerned that it'll muddy the test, by confusing the reader about what I'm testing, i.e. it'll be akin to adding --strict-equality
to the flags. Yes, it still passes, but it's not what's under test.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
@@ -837,6 +837,8 @@ def parse_file( | |||
self.errors.ignored_files.add(path) | |||
tree = parse(source, path, id, self.errors, options=options) | |||
tree._fullname = id | |||
if options.use_builtins_fixtures and id in CORE_BUILTIN_MODULES: | |||
tree._is_typeshed_file = True |
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'd rather not do this if this can silence errors if test fixtures have issues. It would be better to either add a minimal custom fixture that is only used in the relevant test cases or to omit the test cases that need this (I trust that you've tested it already).
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.
_is_typeshed_file
does not silence all errors, though.
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 premise of errors in fixtures becoming obscured concerned me too, but having the test environment closer to actual environment seemed more prudent.
If you feel particularly iffy about it, sure, I can add # type:ignore[misc]
to a handful of places in the fixtures.
[case testDisallowIncompleteDefsAttrsNoAnnotations] | ||
# flags: --disallow-incomplete-defs | ||
[case testDisallowUntypedDefsAttrsNoAnnotations] | ||
# flags: --disallow-untyped-defs |
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.
Hmm I'm a little worried about it (see my comment). If there is no other way, it's fine to omit the test cases.
@JukkaL another look? |
There's no source code to fix for such functions, so there's no use checking them.
Fixes #16454.
Related
attrs
changeSince this caused a false positive for attrs with missing annotations, I've added an explicit check for that. I'm co-opting
--disallow-untyped-defs
for it.One regression is that you can no longer use
--disallow-incomplete-defs
to disallow incomplete but allow wholly untyped classes, e.g. disallowbut allow
This was somewhat of a hack to begin with (
--disallow-*-defs
relates to function, not class definitions), so I'm fine with it.