Skip to content

Commit 0cc75eb

Browse files
committed
Deduplicate constraints before solving
1 parent 7d9dcb6 commit 0cc75eb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mypy/constraints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def infer_constraints_for_callable(
251251
)
252252
c = infer_constraints(callee.arg_types[i], actual_type, SUPERTYPE_OF)
253253
constraints.extend(c)
254+
254255
if (
255256
param_spec
256257
and not any(c.type_var == param_spec.id for c in constraints)
@@ -270,6 +271,8 @@ def infer_constraints_for_callable(
270271
),
271272
)
272273
)
274+
275+
constraints = [c for i, c in enumerate(constraints) if c not in constraints[:i]]
273276
if any(isinstance(v, ParamSpecType) for v in callee.variables):
274277
# As a perf optimization filter imprecise constraints only when we can have them.
275278
constraints = filter_imprecise_kinds(constraints)

0 commit comments

Comments
 (0)