The following code fails mypy type checking:
from lsprotocol.types import WorkspaceEdit, TextEdit, Range, Position
pos = Position(0, 0)
changes = {"file:///tmp/foo.txt": [TextEdit(Range(pos, pos), new_text="hello world")]}
WorkspaceEdit(changes=changes)
Because changes is a dict[str, list[TextEdit]] while WorkspaceEdit's changes expects a dict[str, Sequence[TextEdit]] and dict is invariant -- but we can't actually create a Sequence!
I think the type annotations should probably use Mapping instead of Dict?
The following code fails mypy type checking:
Because
changesis adict[str, list[TextEdit]]while WorkspaceEdit'schangesexpects adict[str, Sequence[TextEdit]]anddictis invariant -- but we can't actually create aSequence!I think the type annotations should probably use
Mappinginstead ofDict?