-
Notifications
You must be signed in to change notification settings - Fork 258
Tweak scope of # type: ignore
in PEP 484
#292
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
Comments
I agree, while placing |
Agreed. |
Refining the extent to the enclosing scope (module/function/class) makes sense, but any narrower might be tricky.
|
I think that in Mark's example the second The trickier bit is whether assignments still get inferred:
What's the type of x here? |
if-else may be relatively easy but what about try-except-finally? What is the motivation for this? |
I would definitely like to ignore a conditional block full of platform-specific imports. (E.g. if I have no stubs for them.) I wouldn't want to have a syntax where a The motivation is to define a syntax that is easy to understand and syntactically orthogonal. Given that we have at least two use cases (ignore a while function, ignore a branch of a conditional), the best approach seems to be to define the scope of |
I'm not sure if it's abusing it a bit, but what about making with no_type_check():
'a' + 1 Here the block scope is very obvious to a reader (because context managers are conceptually tied to a block). I think this eliminates all ambiguity about else branches or try/except being covered or not. OTOH it adds an indentation level, and it's mixing a bit with a run-time concept like context managers with something that is very not run-time. |
|
I'd stay away from a context manager -- people expect runtime behavior from
those.
|
PEP 484 currently says:
I think that's excessive. It should probably be limited to the current indented block, e.g.
The text was updated successfully, but these errors were encountered: