basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py a = 1 a = 2 # should be an error imo ``` ```py a: var = 1 a = 2 # yeah, that's ok ```
```py a: int | str = 1 reveal_type(a) # int | str a = "" reveal_type(a) # str ``` This is actually redefining a as `str`, not reassigning as part...
```py class A: ... a: A a or 1 # error: unreachable ``` While not pythonic, final by default is actually better? 😳 related: #38
```py a = 1 debug_type(a) ``` ``` > mypy test.py test.py:1:1: note: Debug type of "a": test.py:1:1: note: upper bound: int (inferred) test.py:1:1: note: narrowed type: Literal[1], narrowed on line...
What about: ```py import sys from basedtyping import ModuleType a: ModuleType[sys] = sys ``` OR, seeing as modules are instances. we could just allow the plain: ```py import sys a:...
In most cases, mypy should be able to figure out the bulk of missing type annotations. Currently `stubgen` does semanal, but it could use 'checker' as well.
Maintaining `__all__` is extremely painful, what about an `export` decorator (not sure about attributes though) ```py def export(fn: Fn) -> Fn: mod = fn.__module__ if hasattr(mod, "__all__"): isinstance(mod.__all__, list): mod.__all__.append(fn.__name__)...
I think it would be pretty useful if there was a simplified way of using `stubgen` that would: - run `stubgen` for all deps with missing types - add them...