Message360611
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 |
|
Date |
User |
Action |
Args |
2020-01-24 11:48:40 | lopek | set | recipients:
+ lopek |
2020-01-24 11:48:40 | lopek | set | messageid: <1579866520.75.0.652812484582.issue39442@roundup.psfhosted.org> |
2020-01-24 11:48:40 | lopek | link | issue39442 messages |
2020-01-24 11:48:40 | lopek | create | |
|