PEP 591: some minor cleanups (#994)

- Fix some typos
 - Clarify that @final can't be used on non-method functions
This commit is contained in:
Michael J. Sullivan 2019-04-15 16:57:52 -07:00 committed by Guido van Rossum
parent 5165c953e6
commit c4c4bd7b9c
1 changed files with 3 additions and 3 deletions

View File

@ -57,7 +57,7 @@ situations:
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
is expected (for example as a field name for ``NamedTuple``, a tuple
of types passed to ``isinstance``, or an argument to a function
with arguments of ``Literal`` type [#PEP-586]_).
@ -115,6 +115,8 @@ implementation (or on the first overload, for stubs)::
def method(self, x=None):
...
It is an error to use ``@final`` on a non-method function.
The ``Final`` annotation
------------------------
@ -175,8 +177,6 @@ names in type-checked code::
for x in [1, 2, 3]:
FOO: Final = x # Error: Cannot use Final inside a loop
error: Cannot use Final inside a loop
Additionally, a type checker should prevent final attributes from
being overridden in a subclass::