44
44
45
45
_Model = models .Model
46
46
_Field = models .Field [Any , Any ]
47
- CharField = models .CharField [str , str ]
48
- IntegerField = models .IntegerField [int , int ]
47
+ CharField = models .CharField [Any , Any ]
48
+ IntegerField = models .IntegerField [Any , Any ]
49
49
ForeignKey = models .ForeignKey [Any , Any ]
50
50
51
51
_StateValue = str | int
@@ -168,10 +168,10 @@ def get_transition(self, source: str) -> Transition | None:
168
168
169
169
def add_transition (
170
170
self ,
171
- method : Callable [..., str | int | None ],
171
+ method : Callable [..., _StateValue | Any ],
172
172
source : str ,
173
- target : str | int ,
174
- on_error : str | int | None = None ,
173
+ target : _StateValue ,
174
+ on_error : _StateValue | None = None ,
175
175
conditions : list [Callable [[_Instance ], bool ]] = [],
176
176
permission : str | Callable [[_Instance , UserWithPermissions ], bool ] | None = None ,
177
177
custom : dict [str , _StrOrPromise ] = {},
@@ -225,15 +225,15 @@ def has_transition_perm(self, instance: _Instance, state: str, user: UserWithPer
225
225
else :
226
226
return bool (transition .has_perm (instance , user ))
227
227
228
- def next_state (self , current_state : str ) -> str | int :
228
+ def next_state (self , current_state : str ) -> _StateValue :
229
229
transition = self .get_transition (current_state )
230
230
231
231
if transition is None :
232
232
raise TransitionNotAllowed (f"No transition from { current_state } " )
233
233
234
234
return transition .target
235
235
236
- def exception_state (self , current_state : str ) -> str | int | None :
236
+ def exception_state (self , current_state : str ) -> _StateValue | None :
237
237
transition = self .get_transition (current_state )
238
238
239
239
if transition is None :
@@ -534,9 +534,9 @@ def save(self, *args: Any, **kwargs: Any) -> None:
534
534
535
535
def transition (
536
536
field : FSMFieldMixin ,
537
- source : str | int | Sequence [str | int ] = "*" ,
538
- target : str | int | State | None = None ,
539
- on_error : str | int | None = None ,
537
+ source : _StateValue | Sequence [_StateValue ] = "*" ,
538
+ target : _StateValue | State | None = None ,
539
+ on_error : _StateValue | None = None ,
540
540
conditions : list [Callable [[Any ], bool ]] = [],
541
541
permission : str | Callable [[models .Model , UserWithPermissions ], bool ] | None = None ,
542
542
custom : dict [str , _StrOrPromise ] = {},
@@ -614,7 +614,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
614
614
615
615
616
616
class RETURN_VALUE (State ):
617
- def __init__ (self , * allowed_states : Sequence [str | int ]) -> None :
617
+ def __init__ (self , * allowed_states : Sequence [_StateValue ]) -> None :
618
618
self .allowed_states = allowed_states if allowed_states else None
619
619
620
620
def get_state (self , model : _Model , transition : Transition , result : Any , args : Any = [], kwargs : Any = {}) -> _ToDo :
@@ -625,7 +625,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
625
625
626
626
627
627
class GET_STATE (State ):
628
- def __init__ (self , func : Callable [..., str | int ], states : Sequence [str | int ] | None = None ) -> None :
628
+ def __init__ (self , func : Callable [..., _StateValue | Any ], states : Sequence [_StateValue ] | None = None ) -> None :
629
629
self .func = func
630
630
self .allowed_states = states
631
631
0 commit comments