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 lopek
Recipients lopek
Date 2020-01-24.11:48:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579866520.75.0.652812484582.issue39442@roundup.psfhosted.org>
In-reply-to
Content
I've checked this behaviour under Python 3.7.5 and 3.8.1.

```
from __future__ import annotations
from dataclasses import dataclass, fields

@dataclass
class Foo:
    x: int

print(fields(Foo)[0].type)
```

With annotations imported, the `type` field of Field class becomes a string with a name of a type, and the program outputs 'int'.

Without annotations, the `type` field of Field class is a type, and the program outputs <class 'int'>.

I found this out when using dataclasses_serialization module. Following code works fine when we remove import of annotations:

```
from __future__ import annotations
from dataclasses import dataclass
from dataclasses_serialization.json import JSONSerializer

@dataclass
class Foo:
    x: int

JSONSerializer.deserialize(Foo, {'x': 42})
```

TypeError: issubclass() arg 1 must be a class
History
Date User Action Args
2020-01-24 11:48:40lopeksetrecipients: + lopek
2020-01-24 11:48:40lopeksetmessageid: <1579866520.75.0.652812484582.issue39442@roundup.psfhosted.org>
2020-01-24 11:48:40lopeklinkissue39442 messages
2020-01-24 11:48:40lopekcreate