Skip to content

Commit 8a58b22

Browse files
committed
Fix crash related to AST diff of ParamSpec in mypy daemon (#11567)
Fixes #11566.
1 parent 9a34e6c commit 8a58b22

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

mypy/server/astdiff.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class level -- these are handled at attribute level (say, 'mod.Cls.method'
5454

5555
from mypy.nodes import (
5656
SymbolTable, TypeInfo, Var, SymbolNode, Decorator, TypeVarExpr, TypeAlias,
57-
FuncBase, OverloadedFuncDef, FuncItem, MypyFile, UNBOUND_IMPORTED
57+
FuncBase, OverloadedFuncDef, FuncItem, MypyFile, ParamSpecExpr, UNBOUND_IMPORTED
5858
)
5959
from mypy.types import (
6060
Type, TypeVisitor, UnboundType, AnyType, NoneType, UninhabitedType,
@@ -151,6 +151,10 @@ def snapshot_symbol_table(name_prefix: str, table: SymbolTable) -> Dict[str, Sna
151151
node.normalized,
152152
node.no_args,
153153
snapshot_optional_type(node.target))
154+
elif isinstance(node, ParamSpecExpr):
155+
result[name] = ('ParamSpec',
156+
node.variance,
157+
snapshot_type(node.upper_bound))
154158
else:
155159
assert symbol.kind != UNBOUND_IMPORTED
156160
if node and get_prefix(node.fullname) != name_prefix:

test-data/unit/diff.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,3 +1470,17 @@ x: Union[Callable[[Arg(int, 'y')], None],
14701470
[builtins fixtures/tuple.pyi]
14711471
[out]
14721472
__main__.x
1473+
1474+
[case testChangeParamSpec]
1475+
from typing import ParamSpec, TypeVar
1476+
A = ParamSpec('A')
1477+
B = ParamSpec('B')
1478+
C = TypeVar('C')
1479+
[file next.py]
1480+
from typing import ParamSpec, TypeVar
1481+
A = ParamSpec('A')
1482+
B = TypeVar('B')
1483+
C = ParamSpec('C')
1484+
[out]
1485+
__main__.B
1486+
__main__.C

0 commit comments

Comments
 (0)