implement @no_type_check for class defs #6584
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #607 (which is incorrectly titled).
This adds
TypeInfo.is_no_type_check
, and enablesTypeInfo.fallback_to_any
for classes decorated with@no_type_check
, which is checked in a couple of places to abort the type checker early and stub method types asAny
.I'm not sure confident about my use of
decorator.name in ('no_type_check', 'typing.no_type_check'
insemanal.py
. I seeRefName.fullname = 'typing.no_type_check'
was used elsewhere but it wasn't a RefName in the AST duringsemanal
and I didn't look too far into that.This is my current test:
With
@no_type_check
, mypy throws aMissing return statement
for the nestedgarbage_inner
definition, but suppresses the rest of the type errors for this class and subclass.Without
@no_type_check
, we get this nice pile of errors:TODO (I'd like advice from core contributors on these):
decorator.name
check is correct.no return
error?