1from __future__ import annotations 2USING_STRINGS = True 3 4# dataclass_module_2.py and dataclass_module_2_str.py are identical 5# except only the latter uses string annotations. 6 7from dataclasses import dataclass, InitVar 8from typing import ClassVar 9 10T_CV2 = ClassVar[int] 11T_CV3 = ClassVar 12 13T_IV2 = InitVar[int] 14T_IV3 = InitVar 15 16@dataclass 17class 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 26class 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. 33