basedmypy
basedmypy copied to clipboard
Based Python static type checker with baseline, sane default settings and based typing features
```py def f(): a = [1] # inferred as list[object] because of it's usage later b: list[object] = a ``` - super issue of #519
``` > mypy 100000000000000000000000 errors detected Maybe you should consider `mypy --write-baseline` or adding `allow-any-expression = true` to your config file. ```
Currently mypy will not cache a file if it contains errors, but if all of the errors are baselined then it should cache it.
```py def f(fn: Callable[[int], int]):... f(lambda i: i) # no error, int @f def foo(i): # error return i # Unknown ``` # real life: ```py from typing import Callable...
```py class Base(Generic[T_co]): def foo(t: SafeVariance[T_co]): reveal_type(t) # SafeVariance[T_co] effective 'object' class InvariantDerived(Base[T_co]): def foo(t: Invariant[T_co]): ... reveal_type(t) # Invariant[T_co] class CovariantDerived(Base[T_co]): def foo(t: SafeVariance[T_co]): ... b1: Base[object] = InvariantDerived[int]...
```py class A(Generic[T_co]): def foo(self, t: T_co): print(t) ``` This code is 100% type safe, the usage of `t` is safe. It would be nice if there was a form...
```py WrapperDescriptorType = type(object.__init__) MethodWrapperType = type(object().__str__) MethodDescriptorType = type(str.join) ClassMethodDescriptorType = type(dict.__dict__['fromkeys']) GetSetDescriptorType = type(FunctionType.__code__) MemberDescriptorType = type(FunctionType.__globals__) ```
i think there is another issue similar to this, but just thought i'd reiterate it here
```py import re Regex = re.Pattern[str] pattern: Regex re.search(pattern, "") ```