Skip to content

Commit

Permalink
Fix ParamSpec semanal issue (#10866)
Browse files Browse the repository at this point in the history
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 <>
  • Loading branch information
hauntsaninja authored Jul 25, 2021
1 parent 97b3b90 commit 524c924
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3172,11 +3172,15 @@ def process_paramspec_declaration(self, s: AssignmentStmt) -> bool:
# PEP 612 reserves the right to define bound, covariant and contravariant arguments to
# ParamSpec in a later PEP. If and when that happens, we should do something
# on the lines of process_typevar_parameters
paramspec_var = ParamSpecExpr(
name, self.qualified_name(name), self.object_type(), INVARIANT
)
paramspec_var.line = call.line
call.analyzed = paramspec_var

if not call.analyzed:
paramspec_var = ParamSpecExpr(
name, self.qualified_name(name), self.object_type(), INVARIANT
)
paramspec_var.line = call.line
call.analyzed = paramspec_var
else:
assert isinstance(call.analyzed, ParamSpecExpr)
self.add_symbol(name, call.analyzed, s)
return True

Expand Down

0 comments on commit 524c924

Please sign in to comment.