Configuration through class arguments #11

Open
opened 2025-06-15 19:17:57 +02:00 by mkrd · 0 comments
mkrd commented 2025-06-15 19:17:57 +02:00 (Migrated from github.com)

https://typing.python.org/en/latest/spec/dataclasses.html#dataclass-transform

# Indicate that classes that derive from this class default to
# synthesizing comparison methods.
@typing.dataclass_transform(eq_default=True, order_default=True)
class ModelBase:
    def __init_subclass__(
        cls,
        *,
        init: bool = True,
        frozen: bool = False,
        eq: bool = True,
        order: bool = True,
    ):
        ...

# Example of how this class would be used by code that imports
# from this library:
class CustomerModel(
    ModelBase,
    init=False,
    frozen=True,
    eq=False,
    order=False,
):
    id: int
    name: str
https://typing.python.org/en/latest/spec/dataclasses.html#dataclass-transform ```python # Indicate that classes that derive from this class default to # synthesizing comparison methods. @typing.dataclass_transform(eq_default=True, order_default=True) class ModelBase: def __init_subclass__( cls, *, init: bool = True, frozen: bool = False, eq: bool = True, order: bool = True, ): ... # Example of how this class would be used by code that imports # from this library: class CustomerModel( ModelBase, init=False, frozen=True, eq=False, order=False, ): id: int name: str ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mkrd/statica#11
No description provided.