@@ -81,24 +81,22 @@ def __new__(metacls, clsname, bases, dct, **kwargs):
8181 signature = Signature .merge (* signatures , ** arguments )
8282 argnames = tuple (signature .parameters .keys ())
8383
84- # convert the signature to a dataclass so it can be used later instead of Signature.bind
85- data_cls = signature .to_dataclass (f"{ clsname } DataClass" )
86-
8784 namespace .update (
8885 __module__ = module ,
8986 __qualname__ = qualname ,
9087 __argnames__ = argnames ,
9188 __attributes__ = attributes ,
9289 __match_args__ = argnames ,
9390 __signature__ = signature ,
94- __dataclass__ = data_cls ,
9591 __slots__ = tuple (slots ),
9692 )
9793 return super ().__new__ (metacls , clsname , bases , namespace , ** kwargs )
9894
9995 def __or__ (self , other ):
10096 # required to support `dt.Numeric | dt.Floating` annotation for python<3.10
10197 return Union [self , other ]
98+
99+ __call__ = type .__call__
102100
103101
104102@dataclass_transform ()
@@ -107,9 +105,6 @@ class Annotable(Abstract, metaclass=AnnotableMeta):
107105
108106 __signature__ : ClassVar [Signature ]
109107 """Signature of the class, containing the Argument annotations."""
110-
111- __dataclass__ : ClassVar [type ]
112- """Dataclass with identical signature to this class. Used as a faster alternative to Signature.bind"""
113108
114109 __attributes__ : ClassVar [FrozenDict [str , Annotation ]]
115110 """Mapping of the Attribute annotations."""
@@ -120,21 +115,22 @@ class Annotable(Abstract, metaclass=AnnotableMeta):
120115 __match_args__ : ClassVar [tuple [str , ...]]
121116 """Names of the arguments to be used for pattern matching."""
122117
123- @classmethod
124- def __create__ (cls , * args : Any , ** kwargs : Any ) -> Self :
125- # construct the instance by passing only validated keyword arguments
126- validated_kwargs = cls .__signature__ .validate_nobind_using_dataclass (cls , * args , ** kwargs )
127- return super ().__create__ (** validated_kwargs )
118+ # @classmethod
119+ # def __create__(cls, *args: Any, **kwargs: Any) -> Self:
120+ # # construct the instance by passing only validated keyword arguments
121+ # validated_kwargs = cls.__signature__.validate_fast (cls, args, kwargs)
122+ # return super().__create__(**validated_kwargs)
128123
129124 @classmethod
130125 def __recreate__ (cls , kwargs : Any ) -> Self :
131126 # bypass signature binding by requiring keyword arguments only
132127 kwargs = cls .__signature__ .validate_nobind (cls , kwargs )
133128 return super ().__create__ (** kwargs )
134129
135- def __init__ (self , ** kwargs : Any ) -> None :
130+ def __init__ (self , * args , ** kwargs : Any ) -> None :
131+ validated_kwargs = self .__signature__ .validate_fast (self .__class__ , args , kwargs )
136132 # set the already validated arguments
137- for name , value in kwargs .items ():
133+ for name , value in validated_kwargs .items ():
138134 object .__setattr__ (self , name , value )
139135 # initialize the remaining attributes
140136 for name , field in self .__attributes__ .items ():
@@ -199,11 +195,12 @@ class Concrete(Immutable, Comparable, Annotable):
199195
200196 __slots__ = ("__args__" , "__precomputed_hash__" )
201197
202- def __init__ (self , ** kwargs : Any ) -> None :
198+ def __init__ (self , * args , ** kwargs : Any ) -> None :
199+ validated_kwargs = self .__signature__ .validate_fast (self .__class__ , args , kwargs )
203200 # collect and set the arguments in a single pass
204201 args = []
205202 for name in self .__argnames__ :
206- value = kwargs [name ]
203+ value = validated_kwargs [name ]
207204 args .append (value )
208205 object .__setattr__ (self , name , value )
209206
0 commit comments