• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from __future__ import annotations
2USING_STRINGS = True
3
4# dataclass_module_1.py and dataclass_module_1_str.py are identical
5# except only the latter uses string annotations.
6
7import dataclasses
8import typing
9
10T_CV2 = typing.ClassVar[int]
11T_CV3 = typing.ClassVar
12
13T_IV2 = dataclasses.InitVar[int]
14T_IV3 = dataclasses.InitVar
15
16@dataclasses.dataclass
17class CV:
18    T_CV4 = typing.ClassVar
19    cv0: typing.ClassVar[int] = 20
20    cv1: typing.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@dataclasses.dataclass
26class IV:
27    T_IV4 = dataclasses.InitVar
28    iv0: dataclasses.InitVar[int]
29    iv1: dataclasses.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