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 types import FunctionType from typing import Callable, Protocol class Named(Protocol): __name__: str __qualname__: str class Foo: @staticmethod def foo(fn: Callable[[str], None] & Named) ->...
```py from basedtyping import Intersection class A: ... class B: ... class C(A, B): ... AB = Intersection[A, B] print(isinstance(C(), AB)) ```
```py a = {1: 1} b = {'a': 1, **a} ```
```py a = [1] if bool() else [""] # fail b = [1] or [""]# fail ``` this should be `list[int] | list[str]` but, it's epic fail instead
```py from enum import Enum from typing import final class A(Enum): a = 1 class B: ... a: A if a or 1: print("hi") if isinstance(a, B): ... @final class...
```py def f1(a: int, *, b: str=""): ... def f2(a: int, *, b: str): ... def call[**P](fn: Callable[P, None], *args: P.args): fn(*args) call(f1, 1) # ok call(f2, 1) # error...
when setting `"mypy-type-checker.preferDaemon": true` in vscode settings, it doesn't use the daemon. i think because it's expecting the version output to start with "dmypy" but basedmypy prints this instead: ```...