This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ARF1
Recipients ARF1, drhagen, eric.smith, lopek
Date 2020-11-19.09:50:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605779409.9.0.371193021407.issue39442@roundup.psfhosted.org>
In-reply-to
Content
Another counter-intuitive behaviour is the different behaviour of dataclasses depending on whether they were defined with the decorator or the make_dataclass factory method:


from __future__ import annotations
import dataclasses

mytype = int

@dataclasses.dataclass
class MyClass1:
    foo: mytype = 1

MyClass2 = dataclasses.make_dataclass(
    f'MyClass2',
    [('foo', mytype, 1)]
)

print(dataclasses.fields(MyClass1)[0].type)
print(dataclasses.fields(MyClass2)[0].type)


Results in:

mytype
<class 'int'>
History
Date User Action Args
2020-11-19 09:50:09ARF1setrecipients: + ARF1, eric.smith, drhagen, lopek
2020-11-19 09:50:09ARF1setmessageid: <1605779409.9.0.371193021407.issue39442@roundup.psfhosted.org>
2020-11-19 09:50:09ARF1linkissue39442 messages
2020-11-19 09:50:09ARF1create