Skip to content

Commit 524c924

Browse files
authored
Fix ParamSpec semanal issue (#10866)
Recreating equivalent ParamSpecExpr objects causes the equality check in is_same_symbol in add_symbol_table_node to fail, causing a name already defined error. Co-authored-by: hauntsaninja <>
1 parent 97b3b90 commit 524c924

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mypy/semanal.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -3172,11 +3172,15 @@ def process_paramspec_declaration(self, s: AssignmentStmt) -> bool:
31723172
# PEP 612 reserves the right to define bound, covariant and contravariant arguments to
31733173
# ParamSpec in a later PEP. If and when that happens, we should do something
31743174
# on the lines of process_typevar_parameters
3175-
paramspec_var = ParamSpecExpr(
3176-
name, self.qualified_name(name), self.object_type(), INVARIANT
3177-
)
3178-
paramspec_var.line = call.line
3179-
call.analyzed = paramspec_var
3175+
3176+
if not call.analyzed:
3177+
paramspec_var = ParamSpecExpr(
3178+
name, self.qualified_name(name), self.object_type(), INVARIANT
3179+
)
3180+
paramspec_var.line = call.line
3181+
call.analyzed = paramspec_var
3182+
else:
3183+
assert isinstance(call.analyzed, ParamSpecExpr)
31803184
self.add_symbol(name, call.analyzed, s)
31813185
return True
31823186

0 commit comments

Comments
 (0)