-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PEP 591: Adding a final qualifier to typing #990
Conversation
subclasses. (``@property`` can make an attribute read-only but | ||
does not prevent overriding) | ||
* Allowing a name to be used in situations where ordinarily a literal | ||
is expected (for example as a file name for ``NamedTuple``, a tuple |
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.
Sorry I'm late to the party, but I'm guessing "file name" is a typo for "field name".
@final | ||
def method(self, x=None): | ||
... | ||
|
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.
Perhaps say that use of final on a non-method function is an error.
for x in [1, 2, 3]: | ||
FOO: Final = x # Error: Cannot use Final inside a loop | ||
|
||
error: Cannot use Final inside a loop |
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.
Stray line
Is it possible to use |
Yes. |
Maybe there should be an example of that somewhere? (At least in the PEP? And even Python 3 code might want to use type comments if it's straddling with 2.7.) |
I'll make a PR soon |
In the following sample mypy does not raise an error for
Is it a mypy bug or this case is allowed by PEP? |
@sproshev How about adding an annotation to Also please don't spam in this PR. If you have questions, ask them on typing Gitter. |
Initial draft of proposal to add a final qualifier to the typing module