basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py from typing import TYPE_CHECKING if TYPE_CHECKING: import sys sys # expect error: sys is imported as type only ``` - related #166 It's kinda a half measure of fixing...
TypeForm
```py def f(t: TypeExpr[T]) -> T: ... reveal_type(f(int | str)) # int | str a: TypeExpr[int | str] a = int | str # valid UnionType a = int #...
```py def g(x: object) -> "x is list[Any]": return True async def f(t: list[int] | int): if g(t): return reveal_type(t) # list[int] | int, expected int ```
```py from typing import * class A: a: ClassVar[Callable[[int], None]] A().a(1) # too many arguments ``` This is absolute nonsense
```py from __future__ import annotations from typing import * from types import FunctionType fn1: Callable[[], None] reveal_type(fn.__name__) # expect error fn2: Callable[[], None] & FunctionType reveal_type(fn.__name__) # expect 'str' ```...
Needs some more thought, but: # Well ```py class A: a: Callable[[int], str] = lambda x: "" A().a(1) # no type error ``` # So ```py from __future__ import annotations...
```py class A: pass class D(A): def __get__(a, b, c): return None # no error class C: d: A = D() reveal_type(A.d) # A, at runtime it will be None...
### Describe the problem, ie expected/actual result (if it's not blatantly obvious) _No response_ ### Gist to reproduce ```python # mypy: enable-error-code=redundant-expr if isinstance(1, str): # no error ... b...