Skip to content

Commit

Permalink
meta: apply dataclass transform to AtomMeta
Browse files Browse the repository at this point in the history
All members are declared as field specifiers.
  • Loading branch information
MatthieuDartiailh committed Mar 18, 2024
1 parent 330b8fc commit 0c93f70
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions atom/meta/atom_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Tuple,
TypeVar,
Union,
dataclass_transform,
)

from ..catom import (
Expand All @@ -35,6 +36,31 @@
PostValidate,
Validate,
)
from ..coerced import Coerced
from ..containerlist import ContainerList
from ..dict import DefaultDict, Dict as MDict
from ..enum import Enum
from ..event import Event
from ..instance import Instance
from ..list import List as MList
from ..property import Property
from ..scalars import (
Bool,
Bytes,
Callable as MCallable,
Constant,
Float,
FloatRange,
Int,
Range,
ReadOnly,
Str,
Value,
)
from ..set import Set as MSet
from ..signal import Signal
from ..tuple import Tuple as MTuple
from ..typed import Typed
from .annotation_utils import generate_members_from_cls_namespace
from .member_modifiers import set_default
from .observation import ExtendedObserver, ObserveHandler
Expand Down Expand Up @@ -500,6 +526,40 @@ def create_class(self, meta: type) -> type:
return cls


@dataclass_transform(
eq_default=False,
order_default=False,
kw_only_default=True,
field_specifiers=(
set_default,
Member,
Coerced,
ContainerList,
DefaultDict,
MDict,
Enum,
Event,
Instance,
MList,
Property,
Bool,
Bytes,
MCallable,
Constant,
Float,
FloatRange,
Int,
Range,
ReadOnly,
Str,
Value,
MSet,
Signal,
MTuple,
Typed,
),
slots=True,
)
class AtomMeta(type):
"""The metaclass for classes derived from Atom.
Expand Down

0 comments on commit 0c93f70

Please sign in to comment.