PEP-563: Fixed a nested class example (#2007)

The "Backward Compatibility" section in PEP-563 contains an example which
violates Python scoping rules. This PR updates the PEP to say that the example
is not OK and should fail.

See discussion in typing-sig for details [*].

[*]: https://mail.python.org/archives/list/typing-sig@python.org/thread/F2ERQCGB6W6VADR7G6NN4TLMFJECD6EW/
This commit is contained in:
Sergei Lebedev 2021-06-28 19:14:44 +01:00 committed by GitHub
parent b95c2cc10d
commit 9bbc154383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -259,14 +259,15 @@ valid. They can use local names or the fully qualified name. Example::
def method(self) -> C.D.field2: # this is OK
...
def method(self) -> D.field2: # this is OK
...
def method(self) -> D.field2: # this FAILS, class D is local to C
... # and is therefore only available
# as C.D.
def method(self) -> field2: # this is OK
...
def method(self) -> field: # this FAILS, class D doesn't
... # see C's attributes, This was
... # see C's attributes. This was
# already true before this PEP.
In the presence of an annotation that isn't a syntactically valid