]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 13 Jan 2022 01:45:49 +0000 (17:45 -0800)
committerGitHub <noreply@github.com>
Thu, 13 Jan 2022 01:45:49 +0000 (17:45 -0800)
(cherry picked from commit 1de60155d5d01be2924e72fb68dd13d4fd00acd7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_typing.py

index 82b6f8c1c6406414d173d7f5a748abd6fd5c2634..f943aed73614cdf6287a403ab7b0a535b723f08a 100644 (file)
@@ -3104,6 +3104,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: