]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 12 Jan 2022 23:35:44 +0000 (02:35 +0300)
committerGitHub <noreply@github.com>
Wed, 12 Jan 2022 23:35:44 +0000 (15:35 -0800)
Lib/test/test_typing.py

index fd8237a1a8c33f9745e1813ce1e67e8e384ae3b6..c11f6f7c1922433c9335e55a03f3ea19d778b8c7 100644 (file)
@@ -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: