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