Skip to content

Commit

Permalink
Update Human to work with prompt_toolkit >= 2.00
Browse files Browse the repository at this point in the history
  • Loading branch information
marcharper authored and drvinceknight committed Oct 29, 2018
1 parent c99dca1 commit f61d0cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions axelrod/strategies/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from axelrod.action import Action
from axelrod.player import Player
from prompt_toolkit import prompt
from prompt_toolkit.styles import style_from_dict
from prompt_toolkit.token import Token
from prompt_toolkit.styles import Style
from prompt_toolkit.validation import ValidationError, Validator
from pygments.token import Token

C, D = Action.C, Action.D

toolbar_style = style_from_dict({Token.Toolbar: "#ffffff bg:#333333"})
toolbar_style = Style.from_dict({"pygments.toolbar": "#ffffff bg:#333333"})


class ActionValidator(Validator):
Expand All @@ -22,7 +22,8 @@ def validate(self, document) -> None:
text = document.text

if text and text.upper() not in ["C", "D"]:
raise ValidationError(message="Action must be C or D", cursor_position=0)
raise ValidationError(message="Action must be C or D",
cursor_position=0)


class Human(Player):
Expand Down
14 changes: 8 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import mock

MOCK_MODULES = [
'scipy', 'scipy.stats','numpy', 'numpy.linalg', 'numpy.random',
'matplotlib.pyplot', 'matplotlib','matplotlib.transforms', 'tqdm',
'mpl_toolkits.axes_grid1', 'dill', 'multiprocess','prompt_toolkit',
'prompt_toolkit.token', 'prompt_toolkit.styles','prompt_toolkit.validation',
'pandas', 'pandas.util', 'pandas.util.decorators', 'toolz', 'toolz.curried',
'toolz.functoolz', 'cloudpickle', 'dask', 'dask.dataframe']
'cloudpickle', 'dask', 'dask.dataframe', 'dill', 'matplotlib',
'matplotlib.pyplot', 'matplotlib.transforms', 'mpl_toolkits.axes_grid1',
'multiprocess', 'numpy', 'numpy.linalg', 'numpy.random', 'pandas',
'pandas.util', 'pandas.util.decorators', 'prompt_toolkit',
'prompt_toolkit.styles', 'prompt_toolkit.token',
'prompt_toolkit.validation', 'scipy', 'scipy.stats', 'toolz',
'toolz.curried', 'toolz.functoolz', 'tqdm']

for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ hypothesis==3.2
matplotlib>=1.4.2,<3.0.0
numpy>=1.9.2
pandas>=0.18.1
prompt-toolkit>=1.0.7,<2.0.0
prompt-toolkit>=2.0.0
pygments>=2.0.0
scipy>=0.19.0
toolz>=0.8.0
tqdm>=3.4.0

0 comments on commit f61d0cb

Please sign in to comment.