Skip to content

Commit 12db980

Browse files
Refine: allow Any/Unbound types in dict unpacking to avoid false positives
1 parent ba9380d commit 12db980

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mypy/checkexpr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5434,7 +5434,10 @@ def visit_dict_expr(self, e: DictExpr) -> Type:
54345434
if key is None:
54355435
# This is a **expr unpacking. Check that the expression has string keys.
54365436
value_type = get_proper_type(self.accept(value))
5437-
if not self.is_valid_keyword_var_arg(value_type):
5437+
# NEW: Allow Any or Unbound types to reduce false positives in external libraries
5438+
if isinstance(value_type, (AnyType, UnboundType)):
5439+
pass
5440+
elif not self.is_valid_keyword_var_arg(value_type):
54385441
is_mapping = is_subtype(
54395442
value_type, self.chk.named_type("_typeshed.SupportsKeysAndGetItem")
54405443
)

0 commit comments

Comments
 (0)