diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-01-12 17:45:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-12 17:45:49 -0800 |
commit | a468866a67d83a24e3a3c3a0070129773d28bbd9 (patch) | |
tree | 760746dd3d221e2dbe797349ca252e9c75845bb0 | |
parent | 6f9ca53a6ac343a5663cc5c52546acf9a63b605a (diff) | |
download | cpython-git-a468866a67d83a24e3a3c3a0070129773d28bbd9.tar.gz |
bpo-46345: Add a test case for implicit `Optional` class attribute (GH-30535)
(cherry picked from commit 1de60155d5d01be2924e72fb68dd13d4fd00acd7)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r-- | Lib/test/test_typing.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 82b6f8c1c6..f943aed736 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -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: |