Skip to content

Commit 7a15d18

Browse files
committed
Step 6
1 parent 5e333b1 commit 7a15d18

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

django_fsm/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
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
@@ -179,10 +179,10 @@ def get_transition(self, source: str) -> Transition | None:
179179

180180
def add_transition(
181181
self,
182-
method: Callable[..., str | int | None],
182+
method: Callable[..., _StateValue | Any],
183183
source: str,
184-
target: str | int,
185-
on_error: str | int | None = None,
184+
target: _StateValue,
185+
on_error: _StateValue | None = None,
186186
conditions: list[Callable[[_Instance], bool]] = [],
187187
permission: str | Callable[[_Instance, UserWithPermissions], bool] | None = None,
188188
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

574574
def 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

655655
class 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

666666
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:
668668
self.func = func
669669
self.allowed_states = states
670670

0 commit comments

Comments
 (0)