Skip to content
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

Add type hints to alternator #836

Merged
merged 2 commits into from
Feb 1, 2017

Conversation

janga1997
Copy link
Member

#808

@drvinceknight @meatballs. Please review.

@marcharper
Copy link
Member

I wonder if it's enough to type hint the parent class (Player) strategy method, or if overridding the method ignores the base class type hints. Perhaps this depends on the type checker?

@janga1997
Copy link
Member Author

@marcharper that is what I thought too. Seems like the issue we face for ResultSet and ResultSetFromFile?

@marcharper
Copy link
Member

I think testing for ResultSet is better in this case.

@@ -17,7 +18,7 @@ class Alternator(Player):
'manipulates_state': False
}

def strategy(self, opponent):
def strategy(self, opponent: axelrod.player.Player) -> axelrod.actions.Action:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Player is fine here since you imported it; you can import Action from axelrod.actions and then there's no need to import axelrod in line 2.

@drvinceknight drvinceknight merged commit 2526253 into Axelrod-Python:master Feb 1, 2017
@janga1997 janga1997 deleted the typeHint-alternator branch February 1, 2017 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants