From: Nikita Sobolev Date: Wed, 12 Jan 2022 23:35:44 +0000 (+0300) Subject: bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535) X-Git-Tag: v3.11.0a4~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1de60155d5d01be2924e72fb68dd13d4fd00acd7;p=thirdparty%2FPython%2Fcpython.git bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535) --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index fd8237a1a8c3..c11f6f7c1922 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3177,6 +3177,12 @@ class GetTypeHintTests(BaseTestCase): 'my_inner_a2': mod_generics_cache.B.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): @no_type_check class NoTpCheck: