basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
### Gist to reproduce ```python class Foo: @overload def a(self, a: int, /) -> None: ... @overload def a(self, b: str, /) -> None: ... def a(self, c: int |...
```py # type: ignore ``` ``` 👉 mypy test.py --disable-error-code unused-ignore test.py:1:1 error: unused "type: ignore" comment [unused-ignore] ``` You have to supply `--no-warn-unused-ignore`
Is this valid? Sounds valid to me ```py def f(i: list[T]) -> list[T]: ... a: list[str] | list[int] # current reveal_type(f(a)) # Cannot infer type argument 1 of "f" #...
```py from typing import _T as T, TypeVar L = TypeVar("L", bound=list[T]) # error: Type variable "typing._T" is unbound def foo(l: L) -> L | T: # error: A function...
```py # from __future__ import annotations from typing import ForwardRef def foo(a: "asdf") -> True: # literal string `"asdf"` ... MyType: TypeAlias = int | ForwardRef("asdf") # a forward reference...
1.5 will be based on mypy 0.971 and will include: - #340 And anything else that gets finished before that: - #358 - #137 Timeline: - beta1: 26/07/2022 - rc1:...
People use `abc.abstractmethod` for usages that have nothing to do with `abc.ABC`. Also it can't be used on attributes. ```py @abstract class A: a: Abstract[int] class B(A): # error: make...
```py from basedtyping import T def foo(t: T): a: int = t # T reveal_type(t) # T@foo ```
```py a: 1 | 2 # error if TYPE_CHECKING: a: 1 | 2 # no error ```