Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins,builtins
redefining-builtins-modules=future.builtins,builtins


[CLASSES]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- [![Pylint](https://img.shields.io/badge/pylint-9.71%2F10-green.svg)](https://github.com/pytransitions/transitions) -->
<!--[![Name](Image)](Link)-->

A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 2.7+ and 3.0+.
A lightweight, object-oriented state machine implementation in Python with many extensions. Compatible with Python 3.8+.

## Installation

Expand Down Expand Up @@ -453,7 +453,7 @@ So far we have seen how we can give state names and use these names to work with
If you favour stricter typing and more IDE code completion (or you just can't type 'sesquipedalophobia' any longer because the word scares you) using [Enumerations](https://docs.python.org/3/library/enum.html) might be what you are looking for:

```python
import enum # Python 2.7 users need to have 'enum34' installed
import enum
from transitions import Machine

class States(enum.Enum):
Expand Down Expand Up @@ -1210,10 +1210,10 @@ machine = Machine(states=states, transitions=transitions, initial='solid')

### <a name="restoring"></a>(Re-)Storing machine instances

Machines are picklable and can be stored and loaded with `pickle`. For Python 3.3 and earlier `dill` is required.
Machines are picklable and can be stored and loaded with `pickle`.

```python
import dill as pickle # only required for Python 3.3 and earlier
import pickle

m = Machine(states=['A', 'B', 'C'], initial='A')
m.to_B()
Expand Down
1 change: 0 additions & 1 deletion binder/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
six
graphviz
3 changes: 1 addition & 2 deletions examples/Frequently asked questions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@
"outputs": [],
"source": [
"from transitions import Machine, Transition\n",
"from six import string_types\n",
"\n",
"class DependingTransition(Transition):\n",
"\n",
Expand All @@ -464,7 +463,7 @@
" self.execute = super(DependingTransition, self).execute\n",
"\n",
" def execute(self, event_data):\n",
" func = getattr(event_data.model, self._func) if isinstance(self._func, string_types) \\\n",
" func = getattr(event_data.model, self._func) if isinstance(self._func, str) \\\n",
" else self._func\n",
" self._result = func(*event_data.args, **event_data.kwargs)\n",
" super(DependingTransition, self).execute(event_data)\n",
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import nox


python = ["3.10", "3.11", "3.12", "3.13"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
nox.options.stop_on_first_error = True


Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
six
1 change: 0 additions & 1 deletion requirements_mypy.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mypy
graphviz
types-six
1 change: 0 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ pytest-cov
pytest-runner
pytest-xdist
mock
dill
pycodestyle
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@
"transitions.tests": ["data/*"],
},
include_package_data=True,
install_requires=["six"],
extras_require=extras_require,
tests_require=tests_require,
license="MIT",
download_url="https://github.com/pytransitions/transitions/archive/%s.tar.gz"
% __version__,
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
12 changes: 3 additions & 9 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock

if TYPE_CHECKING:
from typing import Sequence
Expand Down Expand Up @@ -559,10 +559,7 @@ def on_enter_B(self, event):

def test_pickle(self):
import sys
if sys.version_info < (3, 4):
import dill as pickle
else:
import pickle
import pickle

states = ['A', 'B', 'C', 'D']
# Define with list of dictionaries
Expand All @@ -581,10 +578,7 @@ def test_pickle(self):

def test_pickle_model(self):
import sys
if sys.version_info < (3, 4):
import dill as pickle
else:
import pickle
import pickle

self.stuff.to_B()
dump = pickle.dumps(self.stuff)
Expand Down
13 changes: 3 additions & 10 deletions tests/test_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock

try:
import enum
from enum import Enum
except ImportError:
enum = None # type: ignore

# placeholder for Python < 3.4 without enum
class Enum: # type: ignore
pass
import enum
from enum import Enum

if TYPE_CHECKING:
from typing import List, Dict, Sequence, Union, Type
Expand Down
13 changes: 3 additions & 10 deletions tests/test_nesting.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# -*- coding: utf-8 -*-
try:
from builtins import object
except ImportError:
pass

import sys
import tempfile
Expand All @@ -20,7 +16,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock

try:
# Just to skip tests if graphviz not installed
Expand All @@ -36,7 +32,7 @@
default_separator = NestedState.separator


class Dummy(object):
class Dummy:
pass


Expand Down Expand Up @@ -296,10 +292,7 @@ def test_ordered_transitions(self):

def test_pickle(self):
print("separator", self.state_cls.separator)
if sys.version_info < (3, 4):
import dill as pickle
else:
import pickle
import pickle

states = ['A', 'B', {'name': 'C', 'children': ['1', '2', {'name': '3', 'children': ['a', 'b', 'c']}]},
'D', 'E', 'F']
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock


class TestParallel(TestNested):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock


if TYPE_CHECKING:
Expand Down
12 changes: 3 additions & 9 deletions tests/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock # type: ignore
from mock import MagicMock

if TYPE_CHECKING:
from typing import List, Type, Tuple, Any
Expand Down Expand Up @@ -85,10 +85,7 @@ def test_conditional_access(self):

def test_pickle(self):
import sys
if sys.version_info < (3, 4):
import dill as pickle
else:
import pickle
import pickle

# go to non initial state B
self.stuff.to_B()
Expand Down Expand Up @@ -253,10 +250,7 @@ def on_enter_A(self):

def test_pickle(self):
import sys
if sys.version_info < (3, 4):
import dill as pickle
else:
import pickle
import pickle

states = ['A', 'B', {'name': 'C', 'children': ['1', '2', {'name': '3', 'children': ['a', 'b', 'c']}]},
'D', 'E', 'F']
Expand Down
2 changes: 1 addition & 1 deletion transitions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
transitions
-----------

A lightweight, object-oriented state machine implementation in Python. Compatible with Python 2.7+ and 3.0+.
A lightweight, object-oriented state machine implementation in Python. Compatible with Python 3.8+.
"""

from __future__ import absolute_import
Expand Down
Loading