Upload dataclass.py with huggingface_hub
Browse files311 unmodified lines3123133143153153163173183173193203213223233243233253263273283 unmodified lines332333334333334335336337338339340311 unmodified lines allowing checks and alterations to be made at the time of class creation, providing more control.
Example: ``` .. highlight:: python .. code-block:: python
class Parent(Dataclass): final_field: int = FinalField(1) # this field cannot be overridden final_field: int = FinalField(1) # this field cannot be overridden required_field: str = RequiredField() also_required_field: float abstract_field: int = AbstractField()
class Child(Parent): abstract_field = 3 # now once overridden, this is no longer abstract abstract_field = 3 # now once overridden, this is no longer abstract required_field = Field(name="required_field", default="provided", type=str)
class Mixin(Dataclass):3 unmodified lines pass
grand_child = GrandChild() logging.info(grand_child.to_dict()) ``` logger.info(grand_child.to_dict())
... """
__allow_unexpected_arguments__ = Falsedataclass.py+7-5