Skip to content

Commit 3f96820

Browse files
meta: apply dataclass transform to AtomMeta
All members are declared as field specifiers.
1 parent d6a1b11 commit 3f96820

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

atom/meta/atom_meta.py

+60
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
Tuple,
2525
TypeVar,
2626
Union,
27+
dataclass_transform,
2728
)
2829

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

503529

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

0 commit comments

Comments
 (0)