diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d94556..e4bddd9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ default_language_version: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0 + rev: 9136088a246768144165fcc3ecc3d31bb686920a # v3.3.0 hooks: - id: trailing-whitespace # Replaces or checks mixed line ending @@ -28,8 +28,8 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://gitlab.com/pycqa/flake8 - rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3 + rev: fb91b994ed4adf4f2b4890e7bdba82f57e3a81df # 3.8.4 hooks: - id: flake8 additional_dependencies: - - hacking>=3.0.1,<3.1.0 + - hacking>=3.1.0,<4.0 diff --git a/automaton/machines.py b/automaton/machines.py index f57d313..896c4ce 100644 --- a/automaton/machines.py +++ b/automaton/machines.py @@ -15,7 +15,6 @@ import collections import prettytable -import six from automaton import _utils as utils from automaton import exceptions as excp @@ -54,9 +53,9 @@ def _convert_to_states(state_space): def _orderedkeys(data, sort=True): if sort: - return sorted(six.iterkeys(data)) + return sorted(data) else: - return list(six.iterkeys(data)) + return list(data) class _Jump(object): @@ -178,10 +177,10 @@ class FiniteMachine(object): if state in self._states: raise excp.Duplicate("State '%s' already defined" % state) if on_enter is not None: - if not six.callable(on_enter): + if not callable(on_enter): raise ValueError("On enter callback must be callable") if on_exit is not None: - if not six.callable(on_exit): + if not callable(on_exit): raise ValueError("On exit callback must be callable") self._states[state] = { 'terminal': bool(terminal), @@ -225,7 +224,7 @@ class FiniteMachine(object): if state not in self._states: raise excp.NotFound("Can not add a reaction to event '%s' for an" " undefined state '%s'" % (event, state)) - if not six.callable(reaction): + if not callable(reaction): raise ValueError("Reaction callback must be callable") if event not in self._states[state]['reactions']: self._states[state]['reactions'][event] = (reaction, args, kwargs) @@ -380,19 +379,19 @@ class FiniteMachine(object): @property def states(self): """Returns the state names.""" - return list(six.iterkeys(self._states)) + return list(self._states) @property def events(self): """Returns how many events exist.""" c = 0 - for state in six.iterkeys(self._states): + for state in self._states: c += len(self._transitions[state]) return c def __iter__(self): """Iterates over (start, event, end) transition tuples.""" - for state in six.iterkeys(self._states): + for state in self._states: for event, target in self._transitions[state].items(): yield (state, event, target.name) @@ -515,7 +514,7 @@ class HierarchicalFiniteMachine(FiniteMachine): """ super(HierarchicalFiniteMachine, self).initialize( start_state=start_state) - for data in six.itervalues(self._states): + for data in self._states.values(): if 'machine' in data: nested_machine = data['machine'] nested_start_state = None diff --git a/automaton/runners.py b/automaton/runners.py index af8d463..485d00c 100644 --- a/automaton/runners.py +++ b/automaton/runners.py @@ -14,8 +14,6 @@ import abc -import six - from automaton import exceptions as excp from automaton import machines @@ -26,8 +24,7 @@ _JUMPER_NOT_FOUND_TPL = ("Unable to progress since no reaction (or" " in response to event '%s')") -@six.add_metaclass(abc.ABCMeta) -class Runner(object): +class Runner(metaclass=abc.ABCMeta): """Machine runner used to run a state machine. Only **one** runner per machine should be active at the same time (aka diff --git a/automaton/tests/test_fsm.py b/automaton/tests/test_fsm.py index bbdb9a8..fe79271 100644 --- a/automaton/tests/test_fsm.py +++ b/automaton/tests/test_fsm.py @@ -20,7 +20,6 @@ from automaton import exceptions as excp from automaton import machines from automaton import runners -import six from testtools import testcase @@ -262,13 +261,13 @@ class FSMTest(testcase.TestCase): self.assertFalse(self.jumper.terminated) self.assertEqual([('down', 'up'), ('up', 'down'), ('down', 'up')], up_downs) - self.assertRaises(StopIteration, six.next, it) + self.assertRaises(StopIteration, next, it) def test_run_send_fail(self): up_downs = [] runner = runners.FiniteRunner(self.jumper) it = runner.run_iter('jump') - up_downs.append(six.next(it)) + up_downs.append(next(it)) self.assertRaises(excp.NotFound, it.send, 'fail') it.close() self.assertEqual([('down', 'up')], up_downs) @@ -364,7 +363,7 @@ class HFSMTest(FSMTest): def phone_reaction(old_state, new_state, event, chat_iter): try: - six.next(chat_iter) + next(chat_iter) except StopIteration: return 'finish' else: diff --git a/lower-constraints.txt b/lower-constraints.txt index d6fcf6b..2ee46ae 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -1,4 +1,5 @@ appdirs==1.3.0 +argparse==0.9.0 cliff==3.1.0 cmd2==0.8.9 coverage==4.0 @@ -17,7 +18,6 @@ pyparsing==2.4.7 pyperclip==1.8.0 python-mimeparse==1.6.0 python-subunit==1.0.0 -PyYAML==3.12 reno==3.1.0 requests==2.14.2 requestsexceptions==1.2.0 @@ -26,7 +26,9 @@ stestr==2.0.0 stevedore==1.20.0 testrepository==0.0.20 testtools==2.2.0 +toml==0.9.3 traceback2==1.4.0 unittest2==1.1.0 +virtualenv==20.0.8 voluptuous==0.11.7 wcwidth==0.2.4 diff --git a/requirements.txt b/requirements.txt index b3e3d6b..f6bd8c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,5 @@ # See: https://bugs.launchpad.net/pbr/+bug/1384919 for why this is here... pbr!=2.1.0,>=2.0.0 # Apache-2.0 -# Python 2->3 compatibility library. -six>=1.10.0 # MIT - # For pretty formatting machines/state tables... PrettyTable<0.8,>=0.7.2 # BSD diff --git a/test-requirements.txt b/test-requirements.txt index 57b96ee..a3c3726 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,12 +2,9 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=3.0,<3.1.0 # Apache-2.0 - coverage!=4.4,>=4.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 stestr>=2.0.0 # Apache-2.0 testtools>=2.2.0 # MIT reno>=3.1.0 # Apache-2.0 -pre-commit>=2.6.0 # MIT diff --git a/tox.ini b/tox.ini index 8d2ba69..61d52d3 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,8 @@ deps = commands = stestr run --slowest {posargs} [testenv:pep8] +deps = + pre-commit>=2.6.0 # MIT commands = pre-commit run -a [testenv:venv]