Eric V. Smith | 2a7bacb | 2018-05-15 22:44:27 -0400 | [diff] [blame] | 1 | #from __future__ import annotations |
| 2 | USING_STRINGS = False |
| 3 | |
| 4 | # dataclass_module_2.py and dataclass_module_2_str.py are identical |
| 5 | # except only the latter uses string annotations. |
| 6 | |
| 7 | from dataclasses import dataclass, InitVar |
| 8 | from typing import ClassVar |
| 9 | |
| 10 | T_CV2 = ClassVar[int] |
| 11 | T_CV3 = ClassVar |
| 12 | |
| 13 | T_IV2 = InitVar[int] |
| 14 | T_IV3 = InitVar |
| 15 | |
| 16 | @dataclass |
| 17 | class CV: |
| 18 | T_CV4 = ClassVar |
| 19 | cv0: ClassVar[int] = 20 |
| 20 | cv1: ClassVar = 30 |
| 21 | cv2: T_CV2 |
| 22 | cv3: T_CV3 |
| 23 | not_cv4: T_CV4 # When using string annotations, this field is not recognized as a ClassVar. |
| 24 | |
| 25 | @dataclass |
| 26 | class IV: |
| 27 | T_IV4 = InitVar |
| 28 | iv0: InitVar[int] |
| 29 | iv1: InitVar |
| 30 | iv2: T_IV2 |
| 31 | iv3: T_IV3 |
| 32 | not_iv4: T_IV4 # When using string annotations, this field is not recognized as an InitVar. |