From 13dbe0ed3b846c0cd2331c0f6af4840955974a65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:10:49 +0200 Subject: [PATCH] Bump python-statemachine from 1.0.3 to 2.3.1 (#85) Co-authored-by: Hans Trompert --- requirements.txt | 2 +- setup.cfg | 2 +- src/supa/connection/fsm.py | 26 +++++++------------------- src/supa/db/model.py | 4 ++-- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9ebcdeb0..f56128fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -96,7 +96,7 @@ pynacl==1.5.0 # via paramiko python-dotenv==1.0.1 # via pydantic-settings -python-statemachine==1.0.3 +python-statemachine==2.3.1 # via supa (setup.cfg) pytz==2024.1 # via diff --git a/setup.cfg b/setup.cfg index 6d4f217b..0c652195 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,7 +35,7 @@ install_requires = colorama ~= 0.4.3 click ~= 8.0 pydantic-settings ~= 2.3.1 - python-statemachine ~= 1.0.3 + python-statemachine ~= 2.3.1 sqlalchemy ~= 2.0.30 apscheduler ~= 3.10.4 tabulate ~= 0.9.0 diff --git a/src/supa/connection/fsm.py b/src/supa/connection/fsm.py index 7008b261..54c7c27c 100644 --- a/src/supa/connection/fsm.py +++ b/src/supa/connection/fsm.py @@ -44,19 +44,8 @@ logger = structlog.get_logger(__name__) -class SuPAStateMachine: - """Add logging capabilities to StateMachine. - - The python-statemachine version 0.x allowed class Statemachine to be used as a base class like this: - - class SuPAStateMachine(StateMachine) - - But version 1.x wil trigger a "statemachine.exceptions.InvalidDefinition: There are no states." exception - when there are no states defined in the StateMachine derived class, this is why, for now, - we use multiple inheritance to override the methods, like in: - - class ReservationStateMachine(SuPAStateMachine, StateMachine) - """ +class SuPAStateMachine(StateMachine): + """Add logging capabilities to StateMachine.""" log: BoundLogger @@ -68,11 +57,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: def on_enter_state(self, state: State) -> None: """Statemachine will call this function on every state transition.""" if isinstance(state, State): - connection_id = self.model.connection_id # type: ignore[attr-defined] - self.log.info("State transition", to_state=state.id, connection_id=str(connection_id)) + self.log.info("State transition", to_state=state.id, connection_id=str(self.model.connection_id)) -class ReservationStateMachine(SuPAStateMachine, StateMachine): +class ReservationStateMachine(SuPAStateMachine): """Reservation State Machine. .. image:: /images/ReservationStateMachine.png @@ -99,7 +87,7 @@ class ReservationStateMachine(SuPAStateMachine, StateMachine): ) -class ProvisionStateMachine(SuPAStateMachine, StateMachine): +class ProvisionStateMachine(SuPAStateMachine): """Provision State Machine. .. image:: /images/ProvisionStateMachine.png @@ -116,7 +104,7 @@ class ProvisionStateMachine(SuPAStateMachine, StateMachine): release_confirmed = Releasing.to(Released) -class LifecycleStateMachine(SuPAStateMachine, StateMachine): +class LifecycleStateMachine(SuPAStateMachine): """Lifecycle State Machine. .. image:: /images/LifecycleStateMachine.png @@ -134,7 +122,7 @@ class LifecycleStateMachine(SuPAStateMachine, StateMachine): terminate_confirmed = Terminating.to(Terminated) -class DataPlaneStateMachine(SuPAStateMachine, StateMachine): +class DataPlaneStateMachine(SuPAStateMachine): """DataPlane State Machine. .. image:: /images/DataPlaneStateMachine.png diff --git a/src/supa/db/model.py b/src/supa/db/model.py index 705969e3..b90510fa 100644 --- a/src/supa/db/model.py +++ b/src/supa/db/model.py @@ -262,13 +262,13 @@ def correlation_id(self) -> uuid.UUID: reservation_state = mapped_column( Enum(*[s.value for s in ReservationStateMachine.states]), nullable=False, - default=ReservationStateMachine.ReserveStart.value, # type: ignore[has-type] + default=ReservationStateMachine.ReserveStart.value, ) provision_state = mapped_column(Enum(*[s.value for s in ProvisionStateMachine.states])) lifecycle_state = mapped_column( Enum(*[s.value for s in LifecycleStateMachine.states]), nullable=False, - default=LifecycleStateMachine.Created.value, # type: ignore[has-type] + default=LifecycleStateMachine.Created.value, ) data_plane_state = mapped_column(Enum(*[s.value for s in DataPlaneStateMachine.states])) # need this because the reservation state machine is missing a state