bpo-42904: Change search order of typing.get_type_hints eval (#25632)

While surprising (searching globals before locals in one specific case), this is needed for backwards compatibility.
This commit is contained in:
Ken Jin 2021-04-27 01:31:21 +08:00 committed by GitHub
parent 94549ee728
commit 1b1f9852bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -3016,10 +3016,10 @@ class GetTypeHintTests(BaseTestCase):
{'other': MySet[T], 'return': MySet[T]}
)
def test_get_type_hints_classes(self):
def test_get_type_hints_classes_str_annotations(self):
class Foo:
y = str
x: y
x: 'y'
# This previously raised an error under PEP 563.
self.assertEqual(get_type_hints(Foo), {'x': str})