basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py from __future__ import annotations from typing import Literal, assert_never foo: 1 | 2 if foo == 1: ... elif foo == 2: # error: redundant-expr ... else: assert_never(foo) ```...
```py @overload def f(a: None) -> TypeError["Can't be None"]: ... @overload def f(a: object): ... ``` If we want that overload to be invalid, should it be a decorator instead...
```py dict[str, int] class Type(MappedType): name: str dict[Type.Key, Type.Value] ``` I don't know how to solve `__delitem__`/`clear` yet, but it would be something to do with it's signature indicating that...
```py a: "(int, str)" # error: invalid type comment or annotation ```
Currently the stubs are wrong and say it's just an alias to a special form in `typing`. Which is absolute nonsense, because it isn't a `_SpecialForm` at all
```py class A: def __init__(self): ... class B: def __init__(self, i: int): ... a: type[A] = B a() # no error ``` This is absurd What if we removed the...
```python from typing import Callable, cast, TypeGuard # mypy: disallow-any-explicit=false value: object if callable(value): cast(Callable[[], None], value) # error: non overlapping cast # if we copy its signature from typeshed,...
```py @public def f(): ... @internal def g(): ... ``` and so on and so forth.
```py if TYPE_CHECKING: a = 1 # no corresponding real definition print(a) ``` Of course this doesn't facilitate all usages: ```py if TYPE_CHECKING: from _typedshed import SupportsAmongUs a: SupportsAmongUs #...
```py if TYPE_CHECKING: a: 1 | 2 # no errors def f(self, a: A): ... # no errors class A: ... ```