You could achieve this using the __post_init__
method:
import dataclasses
@dataclasses.dataclass
class Test:
value : int
def __post_init__(self):
self.value = int(self.value)
This method is called following the __init__
method
https://docs.python.org/3/library/dataclasses.html#post-init-processing