PEP 613: remove last open issue; some edits in response to feedback (#1285)
This commit is contained in:
parent
bf9d3a51cc
commit
2aea60e07c
24
pep-0613.rst
24
pep-0613.rst
|
@ -51,9 +51,10 @@ Forward References:
|
||||||
def foo() -> MyType: ...
|
def foo() -> MyType: ...
|
||||||
|
|
||||||
This code snippet should not error so long as :code:`ClassName` is defined
|
This code snippet should not error so long as :code:`ClassName` is defined
|
||||||
later on. However, a type checker is forced to throw spurious errors that
|
later on. However, a type checker is forced to assume that MyType is a value
|
||||||
(1) :code:`MyType` is an unannotated global string, and (2) :code:`MyType`
|
assignment rather than a type alias, and therefore may throw spurious errors
|
||||||
is not a valid type.
|
that (1) :code:`MyType` is an unannotated global string, and (2) :code:`MyType`
|
||||||
|
cannot be used as a return annotation because it is not a valid type.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
@ -101,10 +102,11 @@ Scope Restrictions:
|
||||||
x = ClassName
|
x = ClassName
|
||||||
|
|
||||||
The outer :code:`x` is a valid type alias, but type checkers must error if the
|
The outer :code:`x` is a valid type alias, but type checkers must error if the
|
||||||
inner :code:`x` is ever used as a type. This is confusing because the alias
|
inner :code:`x` is ever used as a type because type aliases cannot be defined
|
||||||
declaration rule is not explicit, and the error is not thrown on the location
|
inside a nested scope.
|
||||||
of the inner type alias declaration but rather on every one of its subsequent
|
This is confusing because the alias declaration rule is not explicit, and because
|
||||||
use cases.
|
a type error will not be thrown on the location of the inner type alias declaration
|
||||||
|
but rather on every one of its subsequent use cases.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
@ -198,14 +200,6 @@ appealing because it still sticks with the :code:`MyType = int` assignment
|
||||||
syntax, and adds some information for the type checker purely as an annotation.
|
syntax, and adds some information for the type checker purely as an annotation.
|
||||||
|
|
||||||
|
|
||||||
Open Issues
|
|
||||||
===========
|
|
||||||
|
|
||||||
|
|
||||||
The current implementation utilizes the :code:`TypeAlias` already defined in :code:`typing.pyi`,
|
|
||||||
but for conciseness there are suggestions to standardize this to a new class, :code:`typing.Alias`.
|
|
||||||
|
|
||||||
|
|
||||||
Copyright
|
Copyright
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue