dataclass fields type shown as string when compiled in cython

Viewed 38

For the following piece of code of a simple dataclass:

from dataclasses import dataclass, field, fields

@dataclass
class Test():

    _id: ObjectId = field(init=False)

    def __post_init__(self):
        self._id = ObjectId()

tt = Test()
fields(tt)

Running it on python directly would give the following object:

(Field(name='_id',type=<class 'bson.objectid.ObjectId'>,default=<dataclasses._MISSING_TYPE object at 0x7ff1d30f6760>,default_factory=<dataclasses._MISSING_TYPE object at 0x7ff1d30f6760>,init=False,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD),)

However, if I ran the following code compiled with cython 3.0.0a11, I get:

(Field(name='_id',type='ObjectId',default=<dataclasses._MISSING_TYPE object at 0x7f80335335b0>,default_factory=<dataclasses._MISSING_TYPE object at 0x7f80335335b0>,init=False,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD),)

Where the _id type is a string value.

Is there anything I am doing wrong or is it a bug in cython? I have opened an issue here as well.

0 Answers
Related