QuantumGhost/ty-mapping-type-error

★ 0Forks 0PythonGitHub ↗Compare

README

Ty Mapping Type-check Error

How to run type check:

uv sync
uv run ty check .

Expected: no error.

Actual:

error[invalid-method-override]: Invalid override of method `get`
    --> main.py:24:9
     |
  24 |     def get(self, key: str, default: str = None) -> str | None:
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Definition is incompatible with `Mapping.get`
     |
    ::: stdlib/typing.pyi:1865:9
     |
1865 |     def get(self, key: object, default: _T, /) -> _VT_co | _T: ...
     |         ----------------------------------------------------- `Mapping.get` defined here
     |
info: parameter `key` has an incompatible type: `object` is not assignable to `str`
info: This violates the Liskov Substitution Principle

error[invalid-parameter-default]: Default value of type `None` is not assignable to annotated parameter type `str`
  --> main.py:24:29
   |
24 |     def get(self, key: str, default: str = None) -> str | None:
   |                             ^^^^^^^^^^^^^^^^^^^
   |

Found 2 diagnostics

Contributors

QuantumGhost

Issues