4 ms·
It's not mypy issue. Comparing to TS python typehints (spec wise) are a joke. It's started as bolted on adhoc solution and evolved quite chaotically. For exampl
by bvrmn 1y ago
It's not mypy issue. Comparing to TS python typehints (spec wise) are a joke. It's started as bolted on adhoc solution and evolved quite chaotically. For example [1]. TS doesn't require a special decorator (sic!) to make your custom classes to be picked up by type checkers.
Or how make a wrapper function with args and kwargs to pass through?
[1]: https://docs.python.org/3/library/typing.html#typing.dataclass_transform https://docs.python.org/3/library/typing.html#typing.datacla...
- maleldil 1y agoThe dataclass decorator isn't there to make the type checkers understand the class. Its main purpose is to automatically implement trivial methods like the constructor, equality, repr, etc. The type hints make this more convenient, but something similar already existed with attrs.
- bvrmn 1y agoIt's literally stated in the PEP: https://peps.python.org/pep-0681/ https://peps.python.org/pep-0681/ Also: https://github.com/python/mypy/blob/501a07b45af8e44eda665e53526fc590dc5a014e/mypy/semanal_shared.py#L376 https://github.com/python/mypy/blob/501a07b45af8e44eda665e53... Also did you know mypy ignores typing of class decorators? You simply can't return a different type other than type[thisclass].