Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,7 +1799,7 @@ def visit_MatchMapping(self, n: ast3.MatchMapping) -> MappingPattern:
if n.rest is None:
rest = None
else:
rest = NameExpr(n.rest)
rest = self.set_line(NameExpr(n.rest), n)

node = MappingPattern(keys, values, rest)
return self.set_line(node, n)
Expand Down
11 changes: 11 additions & 0 deletions test-data/unit/check-python310.test
Original file line number Diff line number Diff line change
Expand Up @@ -3194,3 +3194,14 @@ def fun(val: str | None):
case types.NoneType():
reveal_type(val) # N: Revealed type is "None"
[builtins fixtures/tuple.pyi]

[case testMatchMappingRestErrorLocation]
data: list[int]
match data:
case [1, *rest]:
...
config: dict[str, object]
match config:
case {"a": 1, **rest}: # E: Incompatible types in capture pattern (pattern captures type "dict[str, object]", variable has type "list[int]")
...
[builtins fixtures/dict.pyi]