-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently setting the attributes of a derived class is not typesafe e.g.
@dataclass
class Position(TypedJsonMixin):
x : int
y : int
p = Position(3, 3)
p.x = 1.2
is still possible. Does it make sense to overwrite the setatt method of the class
currently im doing this manually like this :
def __settattr__(self, name, value):
if isinstance(value, type(getattr(self, name))):
super().__setattr__(self, name, value)
else:
print(f'Type is not matching with that of {name} which is {type(getattr(self, name))}')
im not sure if this has some drawbacks at some point
maybe it would be an option
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request