From 9bbc154383cd08f4a3a441e0c9e780c012d6fd88 Mon Sep 17 00:00:00 2001 From: Sergei Lebedev <185856+superbobry@users.noreply.github.com> Date: Mon, 28 Jun 2021 19:14:44 +0100 Subject: [PATCH] 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/ --- pep-0563.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pep-0563.rst b/pep-0563.rst index ac98282a4..3200edf30 100644 --- a/pep-0563.rst +++ b/pep-0563.rst @@ -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