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

mypy update has broken type hints #1176

Closed
drvinceknight opened this issue May 11, 2018 · 0 comments · Fixed by #1177
Closed

mypy update has broken type hints #1176

drvinceknight opened this issue May 11, 2018 · 0 comments · Fixed by #1177
Assignees

Comments

@drvinceknight
Copy link
Member

Axelrod(master) ✗: python run_mypy.py
axelrod/fingerprint.py:308: error: Value of type variable "AnyStr" of "mkstemp" cannot be "Optional[Any]"
axelrod/fingerprint.py:327: error: Argument 1 to "remove" has incompatible type "Optional[Any]"; expected "Union[bytes, str]"
axelrod/fingerprint.py:446: error: Value of type variable "AnyStr" of "mkstemp" cannot be "Optional[str]"
axelrod/fingerprint.py:459: error: Argument 1 to "remove" has incompatible type "Optional[str]"; expected "Union[bytes, str]"
axelrod/moran.py:105: error: Incompatible types in assignment (expression has type "None", variable has type "str")
axelrod/moran.py:196: error: Invalid index type "Optional[int]" for "List[Any]"; expected type "int"
axelrod/moran.py:213: error: Argument 1 to "pop" of "list" has incompatible type "Optional[int]"; expected "int"
axelrod/moran.py:216: error: Unsupported operand types for >= ("int" and "Optional[int]")
axelrod/moran.py:358: error: Incompatible types in assignment (expression has type "None", variable has type "str")
axelrod/tournament.py:86: error: Incompatible types in assignment (expression has type "None", variable has type "str")
axelrod/tournament.py:87: error: Incompatible types in assignment (expression has type "None", variable has type "int")
axelrod/strategies/apavlov.py:32: error: Incompatible types in assignment (expression has type "None", variable has type "str")
axelrod/strategies/apavlov.py:96: error: Incompatible types in assignment (expression has type "None", variable has type "str")
axelrod/strategies/darwin.py:51: error: Incompatible types in assignment (expression has type "None", variable has type "Dict[Any, Any]")
axelrod/strategies/hunter.py:123: error: Incompatible types in assignment (expression has type "None", variable has type "Tuple[Any]")
axelrod/strategies/memoryone.py:196: error: Argument 1 to "round" has incompatible type "Optional[float]"; expected "float"

Working on this now (as it'll cause CI to break on incoming PRs).

@drvinceknight drvinceknight self-assigned this May 11, 2018
drvinceknight added a commit that referenced this issue May 11, 2018
Closes #1176

Various things I've needed to do:

- In a number of places include that the type is `Optional[]`.
- In a number of places include an `assert` so that `mypy` knows that
  the type is no longer None.
- I have made a minor refactor to the Moran process, I could have used
  asserts but this actually pointed out a spot where I believe the tests
  were incorrect: we were testing a specific situation where
  `MoranProcess.birth` or `MoranProcess.death` should have been called with
  default `index=None` but was actually being tested with `index=0`.
- **I have ignored** a type hint check in `fingerprint.py`: I was
  completely unable to get this one happy

To ensure that any new PRs don't break CI let's merge this under bug fix.
drvinceknight added a commit that referenced this issue May 25, 2018
Closes #1176

Various things I've needed to do:

- In a number of places include that the type is `Optional[]`.
- In a number of places include an `assert` so that `mypy` knows that
  the type is no longer None.
- I have made a minor refactor to the Moran process, I could have used
  asserts but this actually pointed out a spot where I believe the tests
  were incorrect: we were testing a specific situation where
  `MoranProcess.birth` or `MoranProcess.death` should have been called with
  default `index=None` but was actually being tested with `index=0`.
- **I have ignored** a type hint check in `fingerprint.py`: I was
  completely unable to get this one happy

To ensure that any new PRs don't break CI let's merge this under bug fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant