|
6 | 6 | from typing import Iterable, Sequence
|
7 | 7 | from typing_extensions import TypeAlias as _TypeAlias
|
8 | 8 |
|
9 |
| -from mypy.constraints import SUBTYPE_OF, SUPERTYPE_OF, Constraint, infer_constraints, neg_op |
| 9 | +from mypy.constraints import SUBTYPE_OF, SUPERTYPE_OF, Constraint, infer_constraints |
10 | 10 | from mypy.expandtype import expand_type
|
11 | 11 | from mypy.graph_utils import prepare_sccs, strongly_connected_components, topsort
|
12 | 12 | from mypy.join import join_types
|
|
27 | 27 | UninhabitedType,
|
28 | 28 | UnionType,
|
29 | 29 | get_proper_type,
|
30 |
| - remove_dups, |
31 | 30 | )
|
32 | 31 | from mypy.typestate import type_state
|
33 | 32 |
|
@@ -63,10 +62,6 @@ def solve_constraints(
|
63 | 62 | for c in constraints:
|
64 | 63 | extra_vars.extend([v.id for v in c.extra_tvars if v.id not in vars + extra_vars])
|
65 | 64 | originals.update({v.id: v for v in c.extra_tvars if v.id not in originals})
|
66 |
| - if allow_polymorphic: |
67 |
| - # Constraints like T :> S and S <: T are semantically the same, but they are |
68 |
| - # represented differently. Normalize the constraint list w.r.t this equivalence. |
69 |
| -
FBC9
constraints = normalize_constraints(constraints, vars + extra_vars) |
70 | 65 |
|
71 | 66 | # Collect a list of constraints for each type variable.
|
72 | 67 | cmap: dict[TypeVarId, list[Constraint]] = {tv: [] for tv in vars + extra_vars}
|
@@ -335,29 +330,6 @@ def is_trivial_bound(tp: ProperType) -> bool:
|
335 | 330 | return isinstance(tp, Instance) and tp.type.fullname == "builtins.object"
|
336 | 331 |
|
337 | 332 |
|
338 |
| -def normalize_constraints( |
339 |
| - # TODO: delete this function? |
340 |
| - constraints: list[Constraint], |
341 |
| - vars: list[TypeVarId], |
342 |
| -) -> list[Constraint]: |
343 |
| - """Normalize list of constraints (to simplify life for the non-linear solver). |
344 |
| -
|
345 |
| - This includes two things currently: |
346 |
| - * Complement T :> S by S <: T |
347 |
| - * Remove strict duplicates |
348 |
| - * Remove constrains for unrelated variables |
349 |
| - """ |
350 |
| - res = constraints.copy() |
351 |
| - for c in constraints: |
352 |
| - if ( |
353 |
| - isinstance(c.target, TypeVarType) |
354 |
| - or isinstance(c.target, ParamSpecType) |
355 |
| - and not c.target.prefix.arg_types |
356 |
| - ): |
357 |
| - res.append(Constraint(c.target, neg_op(c.op), c.origin_type_var)) |
358 |
| - return [c for c in remove_dups(constraints) if c.type_var in vars] |
359 |
| - |
360 |
| - |
361 | 333 | def transitive_closure(
|
362 | 334 | tvars: list[TypeVarId], constraints: list[Constraint]
|
363 | 335 | ) -> tuple[Graph, Bounds, Bounds]:
|
|
0 commit comments