File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -651,6 +651,9 @@ def try_infer_partial_value_type_from_call(
651651 for item_type in arg_type .args ):
652652 return self .chk .named_generic_type (typename ,
653653 list (arg_type .args ))
654+ elif isinstance (arg_type , AnyType ):
655+ return self .chk .named_type (typename )
656+
654657 return None
655658
656659 def apply_function_plugin (self ,
Original file line number Diff line number Diff line change @@ -1723,6 +1723,21 @@ class C:
17231723 self.a = 1
17241724reveal_type(C().a) # N: Revealed type is 'Union[builtins.int, None]'
17251725
1726+ [case testInferListTypeFromEmptyListAndAny]
1727+ def f():
1728+ return []
1729+
1730+ def g() -> None:
1731+ x = []
1732+ if bool():
1733+ x = f()
1734+ reveal_type(x) # N: Revealed type is 'builtins.list[Any]'
1735+
1736+ y = []
1737+ y.extend(f())
1738+ reveal_type(y) # N: Revealed type is 'builtins.list[Any]'
1739+ [builtins fixtures/list.pyi]
1740+
17261741
17271742-- Inferring types of variables first initialized to None (partial types)
17281743-- ----------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments