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:
parent
5165c953e6
commit
c4c4bd7b9c
|
@ -57,7 +57,7 @@ situations:
|
||||||
subclasses. (``@property`` can make an attribute read-only but
|
subclasses. (``@property`` can make an attribute read-only but
|
||||||
does not prevent overriding)
|
does not prevent overriding)
|
||||||
* Allowing a name to be used in situations where ordinarily a literal
|
* 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
|
of types passed to ``isinstance``, or an argument to a function
|
||||||
with arguments of ``Literal`` type [#PEP-586]_).
|
with arguments of ``Literal`` type [#PEP-586]_).
|
||||||
|
|
||||||
|
@ -115,6 +115,8 @@ implementation (or on the first overload, for stubs)::
|
||||||
def method(self, x=None):
|
def method(self, x=None):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
It is an error to use ``@final`` on a non-method function.
|
||||||
|
|
||||||
The ``Final`` annotation
|
The ``Final`` annotation
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
@ -175,8 +177,6 @@ names in type-checked code::
|
||||||
for x in [1, 2, 3]:
|
for x in [1, 2, 3]:
|
||||||
FOO: Final = x # Error: Cannot use Final inside a loop
|
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
|
Additionally, a type checker should prevent final attributes from
|
||||||
being overridden in a subclass::
|
being overridden in a subclass::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue