basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py T1 = TypeVar("T1", object, int, covariant=True) # expect no error T2 = TypeVar("T2", int, str, covariant=True) # expect error class A(Generic[T1]): def get(self) -> T: ... a_int = A[int]()...
… existing Python code, it will most likely report little to no errors" This was hardly true any more, was it⸮
```py class A[T]: def f[T2: T](self, t2: T2): ... a: A[object] a.f(1) # error: Value of type variable "T2" of "f" of "A" cannot be "int" ``` - related #402
```py a = 1 del a print(f"{a}") # error: helpful-string ```
```py from typing import Callable def f1[T = object](t: T = 1) -> T: ... # type: ignore[empty-body, assignment] def f2[T](fn: Callable[[], T]) -> T: ... # type: ignore[empty-body] f2(f1)...
```py from typing import Callable def f[T](x: Callable[[], T] | Callable[[list[object]], T]) -> T: ... a: list[int] | list[str] = f(list) # Argument 1 to "f" has incompatible type "type[list[_T]]";...
- resolves #286
- resolves #717
- resolves #752 - resolves #721 - resolves #714 - resolves #709 - resolves #696 - resolves #364
- resolves #466 - resolves #175