45
45
46
46
_Model = models .Model
47
47
_Field = models .Field [Any , Any ]
48
- CharField = models .CharField [str , str ]
49
- IntegerField = models .IntegerField [int , int ]
48
+ CharField = models .CharField [Any , Any ]
49
+ IntegerField = models .IntegerField [Any , Any ]
50
50
ForeignKey = models .ForeignKey [Any , Any ]
51
51
52
52
_StateValue = str | int
@@ -179,10 +179,10 @@ def get_transition(self, source: str) -> Transition | None:
179
179
180
180
def add_transition (
181
181
self ,
182
- method : Callable [..., str | int | None ],
182
+ method : Callable [..., _StateValue | Any ],
183
183
source : str ,
184
- target : str | int ,
185
- on_error : str | int | None = None ,
184
+ target : _StateValue ,
185
+ on_error : _StateValue | None = None ,
186
186
conditions : list [Callable [[_Instance ], bool ]] = [],
187
187
permission : str | Callable [[_Instance , UserWithPermissions ], bool ] | None = None ,
188
188
custom : dict [str , _StrOrPromise ] = {},
@@ -237,15 +237,15 @@ def has_transition_perm(self, instance: _Instance, state: str, user: UserWithPer
237
237
else :
238
238
return bool (transition .has_perm (instance , user ))
239
239
240
- def next_state (self , current_state : str ) -> str | int :
240
+ def next_state (self , current_state : str ) -> _StateValue :
241
241
transition = self .get_transition (current_state )
242
242
243
243
if transition is None :
244
244
raise TransitionNotAllowed (f"No transition from { current_state } " )
245
245
246
246
return transition .target
247
247
248
- def exception_state (self , current_state : str ) -> str | int | None :
248
+ def exception_state (self , current_state : str ) -> _StateValue | None :
249
249
transition = self .get_transition (current_state )
250
250
251
251
if transition is None :
@@ -573,9 +573,9 @@ def save(self, *args: Any, **kwargs: Any) -> None:
573
573
574
574
def transition (
575
575
field : FSMFieldMixin ,
576
- source : str | int | Sequence [str | int ] = "*" ,
577
- target : str | int | State | None = None ,
578
- on_error : str | int | None = None ,
576
+ source : _StateValue | Sequence [_StateValue ] = "*" ,
577
+ target : _StateValue | State | None = None ,
578
+ on_error : _StateValue | None = None ,
579
579
conditions : list [Callable [[Any ], bool ]] = [],
580
580
permission : str | Callable [[models .Model , UserWithPermissions ], bool ] | None = None ,
581
581
custom : dict [str , _StrOrPromise ] = {},
@@ -653,7 +653,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
653
653
654
654
655
655
class RETURN_VALUE (State ):
656
- def __init__ (self , * allowed_states : Sequence [str | int ]) -> None :
656
+ def __init__ (self , * allowed_states : Sequence [_StateValue ]) -> None :
657
657
self .allowed_states = allowed_states if allowed_states else None
658
658
659
659
def get_state (self , model : _Model , transition : Transition , result : Any , args : Any = [], kwargs : Any = {}) -> _ToDo :
@@ -664,7 +664,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
664
664
665
665
666
666
class GET_STATE (State ):
667
- def __init__ (self , func : Callable [..., str | int ], states : Sequence [str | int ] | None = None ) -> None :
667
+ def __init__ (self , func : Callable [..., _StateValue | Any ], states : Sequence [_StateValue ] | None = None ) -> None :
668
668
self .func = func
669
669
self .allowed_states = states
670
670
0 commit comments