Skip to content

Commit

Permalink
feat(experimental): remove 'expect' override
Browse files Browse the repository at this point in the history
Scope of expect_override was too narrow and does not solve the typing issue adequately
this reverts #676
  • Loading branch information
aleneum committed Jun 18, 2024
1 parent 4a611dd commit 864c6ef
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 33 deletions.
1 change: 0 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- Bug #610: Decorate models appropriately when `HierarchicalMachine` is passed to `add_state` (thanks @e0lithic)
- Bug #647: Let `may_<trigger>` check all parallel states in processing order (thanks @spearsear)
- Bug: `HSM.is_state` works with parallel states now
- Experimental feature: Use the `transitions.experimental.typing.expect_override` decorator to mark methods as safe for overriding `Machine._checked_assignment` will now override _existing_ model methods (e.g. existing trigger like `melt` or convenience functions like `is_<state>`) if they have a `expect_override` attribute set to `True`.

## 0.9.1 (May 2024)

Expand Down
23 changes: 0 additions & 23 deletions tests/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,22 @@
from unittest.mock import MagicMock

from transitions import Machine
from transitions.experimental.decoration import expect_override


class TestExperimental(TestCase):

def setUp(self) -> None:
self.machine_cls = Machine
return super().setUp()

def test_override_decorator(self):
b_mock = MagicMock()
c_mock = MagicMock()

class Model:

@expect_override
def is_A(self) -> bool:
raise RuntimeError("Should be overridden")

def is_B(self) -> bool:
b_mock()
return False

@expect_override
def is_C(self) -> bool:
c_mock()
return False

model = Model()
machine = self.machine_cls(model, states=["A", "B"], initial="A")
self.assertTrue(model.is_A())
self.assertTrue(model.to_B())
self.assertFalse(model.is_B()) # not overridden with convenience function
self.assertTrue(b_mock.called)
self.assertFalse(model.is_C()) # not overridden yet
self.assertTrue(c_mock.called)
machine.add_state("C")
self.assertFalse(model.is_C()) # now it is!
self.assertEqual(1, c_mock.call_count) # call_count is not increased
self.assertTrue(model.to_C())
self.assertTrue(model.is_C())
self.assertEqual(1, c_mock.call_count)
3 changes: 0 additions & 3 deletions transitions/experimental/decoration.py

This file was deleted.

6 changes: 0 additions & 6 deletions transitions/experimental/decoration.pyi

This file was deleted.

0 comments on commit 864c6ef

Please sign in to comment.