mypy
mypy copied to clipboard
Optional static typing for Python
Following #7188, we can now have: ```python from typing import overload from typing_extensions import Literal class Cat: @overload def __new__(cls, name: Literal['Tabby']) -> 'Tabby': ... @overload def __new__(cls, name: Literal['Kitty'])...
**Bug Report** Custom implemented `__iter__` method on class mismatches when passing positional arguments with asterisk(`*`) **To Reproduce** ```python from typing import Iterator class X: def __iter__(self) -> Iterator[str]: return iter([""])...
**Bug Report** `TypedDict`-based recursive type is flagged as invalid when defined using functional syntax while no issue is reported for analogous class-based definition. **To Reproduce** ```python from typing import List,...
**Bug Report** In the code below, plugging the contravariant TypeVar `T_contra` into the invariant slot in generic `Data` makes mypy forget about the contravariance and the error "Cannot use a...
**Feature** Can we have a separate error code for "Untyped decorator makes function ... untyped"? **Pitch** Many frameworks require the user to wrap their functions in decorators and many of...
**Feature** Improve wording for "incompatible" types based on type narrowing (for boolean types). It should be suggested that the type is generically correct, but can be stated more strictly, otherwise...
```py class A: def foo(self): pass class B(A): def foo(self): def inner(): super().foo() # RuntimeError: super(): no arguments inner() B().foo() ``` [playground](https://mypy-play.net/?mypy=latest&python=3.11&gist=eeba47fb61f5f3e0cb8fe1aff66a194d)
We have decorators that decorate the property not the getter function, and which must be declared BEFORE the property decorator: ```python @mydecorator @property def foo(self): pass ``` Mypy does not...
**Bug Report** Mypy seems to forget about the `@property` decorator if the property is aliased. **To Reproduce** ```python class MyClass: def error(self) -> bool: # Incompatible return value type (got...
**Bug Report** Since https://github.com/python/mypy/issues/5865 was fixed, the following code now type checks: ```python3 from typing import Any, Type def f(typ: Type[Any]) -> Type[Any]: class C(typ): pass return C ``` However...