ARF1 <a...@funke.eu> added the comment:

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'>

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39442>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to