Support for no_type_check decorator#645
Conversation
|
Why the rename? AFAIK the e PEP had the he singular.
|
|
@gvanrossum Both [https://github.com/python/typing/issues/26](your comment) and #557 have the plural form. But I'll change it back to what the PEP say. |
|
Thanks for the PR! I've been busy recently, but I had time for a quick a pass. The implementation has a small limitation in that it detects the decorator based on the name. Something like this would not be detected: from typing import no_type_check as my_annotations
@my_annotations
def foo(x: {1: 'x'}) -> 3: ...I think this would also not work, which is may be a more realistic use case: import typing
@typing.no_type_check
def foo(...) -> 2: ... To implement these properly, we could accept arbitrary expressions in annotations during parsing, and only translate them to types during semantic analysis (but only if there is no |
|
I think the 'as' rename is uninteresting, but the @typing.no_type_check On Tuesday, April 28, 2015, Jukka Lehtosalo notifications@github.com
--Guido van Rossum (on iPad) |
|
This is what I got stuck on; I wasn't happy with the string comparison on 'no_type_check'. Parsing types only after semantic analysis seemed the best solution, but is a lot more work. If it's okay with you, I'll keep the string comparison for now (with both 'no_type_check' and 'typing.no_type_check'), as this feature is quite useful given the existing bugs/limitations in mypy. Separate of this, I'll try to figure out how to move the parsing of type to the semantic analysis phases.
|
…ar expression instead of type annotations.
…ing on a function.
|
@JukkaL The |
|
Here's a diff that fixes the test failures: The current convention is to initialize all 'special' names in |
|
Thanks for the explanation of how the stub works. I've applied your diff and fixed the handling of the |
|
Looks good now! Thanks again for the PR! |
Support for no_type_check decorator
Implements #557.
I've renamed theno_type_checkdecorator tono_type_checks.Currently the typexport-basic tests fails because the
no_type_checkdecorator I added to the typing.py stub shows up in the output of all tests.