bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535)

This commit is contained in:
Nikita Sobolev 2022-01-13 02:35:44 +03:00 committed by GitHub
parent ed57b36c32
commit 1de60155d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -3177,6 +3177,12 @@ class GetTypeHintTests(BaseTestCase):
'my_inner_a2': mod_generics_cache.B.A, 'my_inner_a2': mod_generics_cache.B.A,
'my_outer_a': mod_generics_cache.A}) 'my_outer_a': mod_generics_cache.A})
def test_get_type_hints_classes_no_implicit_optional(self):
class WithNoneDefault:
field: int = None # most type-checkers won't be happy with it
self.assertEqual(gth(WithNoneDefault), {'field': int})
def test_respect_no_type_check(self): def test_respect_no_type_check(self):
@no_type_check @no_type_check
class NoTpCheck: class NoTpCheck: