Skip to content

Commit 26368af

Browse files
committed
Step 6
1 parent 4cb9f7f commit 26368af

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
@@ -44,8 +44,8 @@
4444

4545
_Model = models.Model
4646
_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]
4949
ForeignKey = models.ForeignKey[Any, Any]
5050

5151
_StateValue = str | int
@@ -168,10 +168,10 @@ def get_transition(self, source: str) -> Transition | None:
168168

169169
def add_transition(
170170
self,
171-
method: Callable[..., str | int | None],
171+
method: Callable[..., _StateValue | Any],
172172
source: str,
173-
target: str | int,
174-
on_error: str | int | None = None,
173+
target: _StateValue,
174+
on_error: _StateValue | None = None,
175175
conditions: list[Callable[[_Instance], bool]] = [],
176176
permission: str | Callable[[_Instance, UserWithPermissions], bool] | None = None,
177177
custom: dict[str, _StrOrPromise] = {},
@@ -225,15 +225,15 @@ def has_transition_perm(self, instance: _Instance, state: str, user: UserWithPer
225225
else:
226226
return bool(transition.has_perm(instance, user))
227227

228-
def next_state(self, current_state: str) -> str | int:
228+
def next_state(self, current_state: str) -> _StateValue:
229229
transition = self.get_transition(current_state)
230230

231231
if transition is None:
232232
raise TransitionNotAllowed(f"No transition from {current_state}")
233233

234234
return transition.target
235235

236-
def exception_state(self, current_state: str) -> str | int | None:
236+
def exception_state(self, current_state: str) -> _StateValue | None:
237237
transition = self.get_transition(current_state)
238238

239239
if transition is None:
@@ -534,9 +534,9 @@ def save(self, *args: Any, **kwargs: Any) -> None:
534534

535535
def transition(
536536
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,
540540
conditions: list[Callable[[Any], bool]] = [],
541541
permission: str | Callable[[models.Model, UserWithPermissions], bool] | None = None,
542542
custom: dict[str, _StrOrPromise] = {},
@@ -614,7 +614,7 @@ def get_state(self, model: _Model, transition: Transition, result: Any, args: An
614614

615615

616616
class RETURN_VALUE(State):
617-
def __init__(self, *allowed_states: Sequence[str | int]) -> None:
617+
def __init__(self, *allowed_states: Sequence[_StateValue]) -> None:
618618
self.allowed_states = allowed_states if allowed_states else None
619619

620620
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
625625

626626

627627
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:
629629
self.func = func
630630
self.allowed_states = states
631631

0 commit comments

Comments
 (0)