File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,9 @@ def infer_typing_alias(
316
316
# This is an issue in cases where the aliased class implements it,
317
317
# but the typing alias isn't subscriptable. E.g., `typing.ByteString` for PY39+
318
318
_forbid_class_getitem_access (class_def )
319
+
320
+ # Avoid re-instantiating this class every time it's seen
321
+ node ._explicit_inference = lambda node , context : iter ([class_def ])
319
322
return iter ([class_def ])
320
323
321
324
Original file line number Diff line number Diff line change @@ -650,6 +650,16 @@ def __init__(self, value):
650
650
assert isinstance (slots [0 ], nodes .Const )
651
651
assert slots [0 ].value == "value"
652
652
653
+ @test_utils .require_version (minver = "3.9" )
654
+ def test_typing_no_duplicates (self ):
655
+ node = builder .extract_node (
656
+ """
657
+ from typing import List
658
+ List[int]
659
+ """
660
+ )
661
+ assert len (node .inferred ()) == 1
662
+
653
663
def test_collections_generic_alias_slots (self ):
654
664
"""Test slots for a class which is a subclass of a generic alias type."""
655
665
node = builder .extract_node (
You can’t perform that action at this time.
0 commit comments