mypy
mypy copied to clipboard
Optional static typing for Python
Implement a small collection of generic native class attribute getters and setters to avoid generating custom verbose code for most attributes. Attribute types supported are: - PyObject * (setter: only...
**Feature** This PR introduces a new check for mypy: we now can find incompatible `__post_init__` methods in `@dataclass`es: https://github.com/python/mypy/pull/15503/files#diff-f96a2d6138bc6cdf2a07c4d37f6071cc25c1631afc107e277a28d5b59fc0ef04R1048-R1050 But, the thing is that for now we are using a...
**Bug Report** Accessing an instance of an enum _though another instance_ leads to the wrong type being inferred for the instance. **To Reproduce** See: https://mypy-play.net/?mypy=master&python=3.12&flags=disallow-any-unimported&gist=26f57e606e831442885c45110b8d8650 ```python import enum class Color(enum.Enum):...
Fixes #13823. See also #6406
**Feature** We're often taught that good code is DRY ("don't repeat yourself") – it minimizes redundancy, and with it the possibility that two or more redundant forms won't agree as...
**Bug Report** Consider the following code [[mypy-play.net]](https://mypy-play.net/?mypy=latest&python=3.10&flags=show-error-codes%2Cstrict%2Cwarn-unreachable&gist=1292b7723e365be11e6db5425822465d): ```python from __future__ import annotations from typing import * T = TypeVar('T') class Parent(Sequence[T]): '''a sequence type which is implemented one of two...
**Feature** Taking into consideration the following code (using mypy==1.4.1), the error messages are not very useful in debugging the problem. I have included the Pyright error message for comparison: ```python...
I have witnessed many times when the CI has failed in master due to dependencies changing, these failures have always introduced additional work upon the maintainers. I can suggest adopting...
**Feature** It would be very helpful to have a way of specifying that a container type must be non-empty. **Pitch** As an example of why this feature would be helpful,...
``` import attr @attr.s class Bar: b = attr.ib() @classmethod def make(cls, one: int) -> 'Bar': return cls(one) @attr.s class Foo: a = attr.ib(converter=Bar.make) ``` `error: Unsupported converter, only named...