diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2021-02-28 02:19:24 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-02-28 18:14:22 +0100 |
commit | 04cd51dab30e5e364f9835d2eba4faa7cf362ee9 (patch) | |
tree | 616e804b110b450183ec4dc5689f45a78736f3f5 /tests/unittest_brain.py | |
parent | 40373681b277a672f127ad2e15ec74e74b0bfe44 (diff) | |
download | astroid-git-04cd51dab30e5e364f9835d2eba4faa7cf362ee9.tar.gz |
Improve typing.TypedDict inference
Diffstat (limited to 'tests/unittest_brain.py')
-rw-r--r-- | tests/unittest_brain.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py index dc3f25d4..51311972 100644 --- a/tests/unittest_brain.py +++ b/tests/unittest_brain.py @@ -1188,6 +1188,21 @@ class TypingBrain(unittest.TestCase): inferred = next(node.infer()) self.assertIsInstance(inferred, astroid.Instance) + def test_typedDict(self): + node = builder.extract_node( + """ + from typing import TypedDict + class CustomTD(TypedDict): + var: int + """ + ) + assert len(node.bases) == 1 + inferred_base = next(node.bases[0].infer()) + self.assertIsInstance(inferred_base, nodes.ClassDef, node.as_string()) + typing_module = inferred_base.root() + assert len(typing_module.locals["TypedDict"]) == 1 + assert inferred_base == typing_module.locals["TypedDict"][0] + class ReBrainTest(unittest.TestCase): def test_regex_flags(self): |