I want to restrict a string type by executing a function at the type hint. It seems to not cause any problems, but is it a well-defined practice or has any correspondences anywhere?
An example code excerpt:
class A:
def __str__(self):
return "a"
@dataclass
class B:
var: str(A) + '.txt'
The idea would be var
will be a string that is generated from an A and has '.txt'
suffix.