basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py import sys def main(): if sys.platform == "linux": return print("hi") # Statement is unreachable ``` ```terminal > mypy test.py --platform linux ```
```py def guard(x: object) -> bool: # inferred as "x is int" return isinstance(x, int) def is_even(x: object) -> bool: # inferred as "x is int if True else False"...
```py class A: def __init__(self, *args: object): ... def __call__(self, arg: int | str): ... @overload def f(arg: int): ... @overload def f(arg: int): ... @A def f(): ... ```...
https://github.com/python/mypy/issues/16095 https://github.com/python/mypy/pull/16102#issuecomment-1982172842 (ie, it's based)
There's already `(T, U, V)` for `tuple[T, U, V]` and I think what I wrote is all valid syntax, so I think these shorthands are kind of the obvious way...
```py def f(x: object) -> TypeAssertion[int]: # demarcation is tentative, maybe `Asserts[x is int]` assert isinstance(x, int) a: object f(a) reveal_type(a) # int is ``` # Notes: - Would want...
Okay, so basically, the tests are all convoluted and takes ages because the stdlib loads for each test, so there are all kinds of hacks and workarounds to make them...
```py def f(s: str): for item in a: ... ``` Iterating is most often a mistake. We should have an option to prevent these usages . ```py a: Iterable[str] =...
Variadic tuples should be like `tuple[int]` Variadic tuples could be denoted as `(*int,)` Fixed length tuples should be `(int,)` There is a question about if `tuple[int, ...]` should still be...