basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py def guard(x: object) -> x is int if True else x is str: ... def guard(x: object) -> True if True else x is str: ... ``` likely a...
# unions ```py def guard(a: object, b: object) -> a is int | b is int: ... a: object b: object if guard(a, b): reveal_type((a, b)) # (object, object) c:...
If we could somehow inspect the implementation and determine if it is a 'full typeguard', or just a 'positive typegaurd' ```py def is_positive_int(val: int | str) -> TypeGuard[int]: return isinstance(val,...
- utilize the baseline `target` - don't update offsets if they are within a range - base offsets on the targets offset
```py from typing import overload, Self class A: @overload def __new__(cls, a: int): ... @overload def __new__(cls, a: str, /): ... def __new__(cls, a: int | str): return super().__new__(cls) #...
```py from datetime import date a: date if a == "a": # no error print("hi") ``` This issue is that operators tend to be implemented like: ```py class A: def...
incorrect: ```py def foo(): a: str = 1 # type: ignore[assignment] # error: add a comment on the line above explaining why the error is being ignored ``` correct: ```py...
```py a: int | None a = None for _ in range(2): reveal_type(a) # None a = 1 ``` `a` should be widened to `int | None` at the start...