Skip to content

Add type hints to apavlov #846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 10, 2017
15 changes: 8 additions & 7 deletions axelrod/strategies/apavlov.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from axelrod.actions import Actions

from axelrod.actions import Actions, Action
from axelrod.player import Player

C, D = Actions.C, Actions.D
Expand Down Expand Up @@ -26,11 +27,11 @@ class APavlov2006(Player):
'manipulates_state': False
}

def __init__(self):
def __init__(self) -> None:
super().__init__()
self.opponent_class = None
self.opponent_class = ""

def strategy(self, opponent):
def strategy(self, opponent: Player) -> Action:
# TFT for six rounds
if len(self.history) < 6:
return D if opponent.history[-1:] == [D] else C
Expand Down Expand Up @@ -93,11 +94,11 @@ class APavlov2011(Player):
'manipulates_state': False
}

def __init__(self):
def __init__(self) -> None:
super().__init__()
self.opponent_class = None
self.opponent_class = ""

def strategy(self, opponent):
def strategy(self, opponent: Player) -> Action:
# TFT for six rounds
if len(self.history) < 6:
return D if opponent.history[-1:] == [D] else C
Expand Down
1 change: 1 addition & 0 deletions type_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/alternato
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/ann.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/appeaser.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/averagecopier.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/apavlov.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/axelrod_second.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/backstabber.py
mypy --ignore-missing-imports --follow-imports skip axelrod/strategies/better_and_better.py
Expand Down