If I understand well, ClassVar is a way of creating a class-variable on a dataclass, a variable which won't be considered as a field. So, for example:
@dataclass
class MyData:
name: str
age: int
parent: ClassVar[Optional["MyData"]] = None
jake_data = MyData(name="Jake", age=34)
dataclasses.fields(jake_data) # This will output only two fields, as status is a ClassVar
But if I want to modify parent at the instance level after the instance's initialisation, it should not be a ClassVar, as PEP 526 makes it clear that the ClassVar annotation should only be used for variables which are not replaced at instance level. And I don't want to declare parent as a field with a default value because then it would be... a dataclass field!
For the context: I use libraries that rely on the output of dataclasses.fields, that's why I want it to be a non-field variable.
Is there a pythonic and readable way to do that?
status?statusbyparent) so it is closer to the use I have. As you can see, I am using this variable as a reference. I will need to set it only once, but it needs to be after initialisation.