4545
4646 _Model = models .Model
4747 _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 ]
5050 ForeignKey = models .ForeignKey [Any , Any ]
5151
5252 _StateValue = str | int
@@ -180,10 +180,10 @@ def get_transition(self, source: str) -> Transition | None:
180180
181181 def add_transition (
182182 self ,
183- method : Callable [..., str | int | None ],
183+ method : Callable [..., _StateValue | Any ],
184184 source : str ,
185- target : str | int ,
186- on_error : str | int | None = None ,
185+ target : _StateValue ,
186+ on_error : _StateValue | None = None ,
187187 conditions : list [Callable [[_Instance ], bool ]] = [],
188188 permission : str | Callable [[_Instance , UserWithPermissions ], bool ] | None = None ,
189189 custom : dict [str , _StrOrPromise ] = {},
@@ -237,15 +237,15 @@ def has_transition_perm(self, instance: _Instance, state: str, user: UserWithPer
237237 else :
238238 return bool (transition .has_perm (instance , user ))
239239
240- def next_state (self , current_state : str ) -> str | int :
240+ def next_state (self , current_state : str ) -> _StateValue :
241241 transition = self .get_transition (current_state )
242242
243243 if transition is None :
244244 raise TransitionNotAllowed (f"No transition from { current_state } " )
245245
246246 return transition .target
247247
248- def exception_state (self , current_state : str ) -> str | int | None :
248+ def exception_state (self , current_state : str ) -> _StateValue | None :
249249 transition = self .get_transition (current_state )
250250
251251 if transition is None :
@@ -573,9 +573,9 @@ def save(self, *args: Any, **kwargs: Any) -> None:
573573
574574def transition (
575575 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 ,
579579 conditions : list [Callable [[Any ], bool ]] = [],
580580 permission : str | Callable [[models .Model , UserWithPermissions ], bool ] | None = None ,
581581 custom : dict [str , _StrOrPromise ] = {},
@@ -653,7 +653,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
653653
654654
655655class RETURN_VALUE (State ):
656- def __init__ (self , * allowed_states : Sequence [str | int ]) -> None :
656+ def __init__ (self , * allowed_states : Sequence [_StateValue ]) -> None :
657657 self .allowed_states = allowed_states if allowed_states else None
658658
659659 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
664664
665665
666666class 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 :
668668 self .func = func
669669 self .allowed_states = states
670670
0 commit comments