Skip to content

Commit 0c93f70

Browse files
meta: apply dataclass transform to AtomMeta
All members are declared as field specifiers.
1 parent 330b8fc commit 0c93f70

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

atom/meta/atom_meta.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Tuple,
2424
TypeVar,
2525
Union,
26+
dataclass_transform,
2627
)
2728

2829
from ..catom import (
@@ -35,6 +36,31 @@
3536
PostValidate,
3637
Validate,
3738
)
39+
from ..coerced import Coerced
40+
from ..containerlist import ContainerList
41+
from ..dict import DefaultDict, Dict as MDict
42+
from ..enum import Enum
43+
from ..event import Event
44+
from ..instance import Instance
45+
from ..list import List as MList
46+
from ..property import Property
47+
from ..scalars import (
48+
Bool,
49+
Bytes,
50+
Callable as MCallable,
51+
Constant,
52+
Float,
53+
FloatRange,
54+
Int,
55+
Range,
56+
ReadOnly,
57+
Str,
58+
Value,
59+
)
60+
from ..set import Set as MSet
61+
from ..signal import Signal
62+
from ..tuple import Tuple as MTuple
63+
from ..typed import Typed
3864
from .annotation_utils import generate_members_from_cls_namespace
3965
from .member_modifiers import set_default
4066
from .observation import ExtendedObserver, ObserveHandler
@@ -500,6 +526,40 @@ def create_class(self, meta: type) -> type:
500526
return cls
501527

502528

529+
@dataclass_transform(
530+
eq_default=False,
531+
order_default=False,
532+
kw_only_default=True,
533+
field_specifiers=(
534+
set_default,
535+
Member,
536+
Coerced,
537+
ContainerList,
538+
DefaultDict,
539+
MDict,
540+
Enum,
541+
Event,
542+
Instance,
543+
MList,
544+
Property,
545+
Bool,
546+
Bytes,
547+
MCallable,
548+
Constant,
549+
Float,
550+
FloatRange,
551+
Int,
552+
Range,
553+
ReadOnly,
554+
Str,
555+
Value,
556+
MSet,
557+
Signal,
558+
MTuple,
559+
Typed,
560+
),
561+
slots=True,
562+
)
503563
class AtomMeta(type):
504564
"""The metaclass for classes derived from Atom.
505565

0 commit comments

Comments
 (0)