-
Notifications
You must be signed in to change notification settings - Fork 0
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 .mypy.ini
, pylintrc
and satisfy pylint
, mypy
checks
#11
Conversation
from __future__ import annotations | ||
from typing import TypeVar, Type | ||
|
||
T = TypeVar("T") # pylint: disable=C0103 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pylint 2.12
(or earlier versions) does not work properly with TypeVar
in the (it is fixed in the 2.13).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please create a GitHub issue to update to Pylint 2.13 when it comes out, and to remove the suppression here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | ||
cls.__eq__ = __eq__ | ||
cls.__eq__ = __eq__ # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy
do not allow assigning a function to a method (see here).
@@ -112,10 +112,10 @@ def test_win_condition(self): | |||
Cell(0, 2), False)] | |||
for cells, cell, expect in args_and_expect_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy
does not inference the right type for cells
and the syntax does not allow one to annotate the types of variables when tuple unpacking is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job 👍 Just a few little things.
from __future__ import annotations | ||
from typing import TypeVar, Type | ||
|
||
T = TypeVar("T") # pylint: disable=C0103 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please create a GitHub issue to update to Pylint 2.13 when it comes out, and to remove the suppression here?
@@ -256,23 +259,23 @@ def __last_step(step: int) -> bool: | |||
return step == Board.size() ** 2 - 1 | |||
|
|||
@staticmethod | |||
def __surrender(state: State): | |||
def __surrender(state: State) -> None: | |||
assert state.phase is Phase.INROUND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another assertion:
# for more players this method would have been implemented quite differently
assert State.player_count() is 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment in the example for a reason: I think we need to clarify this new assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -256,23 +259,23 @@ def __last_step(step: int) -> bool: | |||
return step == Board.size() ** 2 - 1 | |||
|
|||
@staticmethod | |||
def __surrender(state: State): | |||
def __surrender(state: State) -> None: | |||
assert state.phase is Phase.INROUND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment in the example for a reason: I think we need to clarify this new assertion.
No description provided.