Skip to content

Commit d7a5d08

Browse files
fixed use get_proper_type before isinstance check
1 parent 55b3bac commit d7a5d08

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

mypy/checkexpr.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ def infer_function_type_arguments(
21002100

21012101
if True: # NEW CODE
21022102
# compute the inner constraints
2103-
inner_constraints = infer_constraints_for_callable(
2103+
_inner_constraints = infer_constraints_for_callable(
21042104
callee_type,
21052105
pass1_args,
21062106
arg_kinds,
@@ -2109,18 +2109,20 @@ def infer_function_type_arguments(
21092109
context=self.argument_infer_context(),
21102110
)
21112111
# HACK: convert "Literal?" constraints to their non-literal versions.
2112-
inner_constraints = [
2113-
Constraint(
2114-
c.original_type_var,
2115-
c.op,
2116-
(
2117-
c.target.copy_modified(last_known_value=None)
2118-
if isinstance(c.target, Instance)
2119-
else c.target
2120-
),
2112+
inner_constraints: list[Constraint] = []
2113+
for constraint in _inner_constraints:
2114+
target = get_proper_type(constraint.target)
2115+
inner_constraints.append(
2116+
Constraint(
2117+
constraint.original_type_var,
2118+
constraint.op,
2119+
(
2120+
target.copy_modified(last_known_value=None)
2121+
if isinstance(target, Instance)
2122+
else target
2123+
),
2124+
)
21212125
)
2122-
for c in inner_constraints
2123-
]
21242126

21252127
# compute the outer solution
21262128
outer_constraints = self.infer_constraints_from_context(callee_type, context)

0 commit comments

Comments
 (0)