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

Conversation

janga1997
Copy link
Member

#808 @drvinceknight @marcharper
mypy produces two errors.
axelrod/strategies/apavlov.py:31: error: Need type annotation for variable axelrod/strategies/apavlov.py:98: error: Need type annotation for variable
It seems like an issue with mypy itself. I'm not sure.

And the local test produces errors which I don't think has anything to do with type hinting.
/home/janga/Axelrod/axelrod/mock_player.py:61: UserWarning: Simulated play mismatch with expected history: Round was (C, C) but (C, D) was expected for player: Adaptive Pavlov 2006 s1, s2, action1, action2, str(player1))
and more of the same error.

@drvinceknight
Copy link
Member

mypy produces two errors.
axelrod/strategies/apavlov.py:31: error: Need type annotation for variable axelrod/strategies/apavlov.py:98: error: Need type annotation for variable
It seems like an issue with mypy itself. I'm not sure.

It does look like a mypy issue. I'm not sure how to deal with it. Any suggestion @marcharper?

And the local test produces errors which I don't think has anything to do with type hinting.
/home/janga/Axelrod/axelrod/mock_player.py:61: UserWarning: Simulated play mismatch with expected history: Round was (C, C) but (C, D) was expected for player: Adaptive Pavlov 2006 s1, s2, action1, action2, str(player1))
and more of the same error.

Don't worry about this, it's just a warning and not a failure. Travis triggered a failure but that was for a timeout on some of our property based tests, I've reset that so we'll see if that fixes itself.

@marcharper
Copy link
Member

@janga1997 please add the strategy file to type_tests.sh

In Python 3.5 we cannot annotate variables, that's a Python 3.6 feature. If you are using Python 3.6 for testing with mypy you may get different results. Travis will check both once you add the file to type_tests.

@janga1997
Copy link
Member Author

janga1997 commented Feb 6, 2017

@marcharper I am using Python 3.5.
But I am sure a similar situation has occurred in previous commits, but it never raised an issue there.
I don't understand what is unique about this situation?

@marcharper
Copy link
Member

I'm not sure really -- can you rebase/merge and run mypy again? I'll take a closer look at the errors.

@marcharper
Copy link
Member

mypy is unhappy because we're using both None and strings for the same variable without declaring its type. Just change both lines to: self.opponent_class = "".

@drvinceknight
Copy link
Member

Since #852 has been merged in there are now merge conflicts @janga1997 :)

@drvinceknight drvinceknight merged commit d278a6e into Axelrod-Python:master Feb 10, 2017
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.

3 participants