File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,9 +68,43 @@ class can be used:
6868 For more information see `official docs <https://docs.python.org/3/library/dataclasses.html >`_
6969and `PEP 557 <https://www.python.org/dev/peps/pep-0557/ >`_.
7070
71- **Note: ** Some functions in the ``dataclasses `` module, such as ``replace() `` and ``asdict() ``,
71+ Caveats/Known Issues
72+ ====================
73+
74+ Some functions in the ``dataclasses `` module, such as ``replace() `` and ``asdict() ``,
7275have imprecise (too permissive) types. This will be fixed in future releases.
7376
77+ Mypy does not yet recognize aliases of ``dataclasses.dataclass ``, and will
78+ probably never recognize dynamically computed decorators. The following examples
79+ do **not ** work:
80+
81+ .. code-block :: python
82+
83+ from dataclasses import dataclass
84+
85+ dataclass_alias = dataclass
86+ def dataclass_wrapper (cls ):
87+ return dataclass(cls )
88+
89+ @dataclass_alias
90+ class AliasDecorated :
91+ """
92+ Mypy doesn't recognize this as a dataclass because it is decorated by an
93+ alias of `dataclass` rather than by `dataclass` itself.
94+ """
95+ attribute: int
96+
97+ @dataclass_wrapper
98+ class DynamicallyDecoarted :
99+ """
100+ Mypy doesn't recognize this as a dataclass because it is decorated by a
101+ function returning `dataclass` rather than by `dataclass` itself.
102+ """
103+ attribute: int
104+
105+ AliasDecorated(attribute = 1 ) # error: Unexpected keyword argument
106+ DynamicallyDecoarted(attribute = 1 ) # error: Unexpected keyword argument
107+
74108 .. _attrs_package :
75109
76110The attrs package
You can’t perform that action at this time.
0 commit comments