-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Cleanup - fix flake8 errors and remove dead code #47
Conversation
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.
Round 1 and overall very good.
But this part with the hanging indents and multiline-statements inside of parantheses definitely have to be changed or if there are good arguments against a change, discussed.
And the weird
... C(
x, y
) ...
looks horrible.
src/Bishop.py
Outdated
for move in self.movesInDirectionFromPos( | ||
currentPosition, direction, self.side | ||
): |
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.
When using a hanging indent the following should be considered; [...] further indentation should be used to clearly distinguish itself as a continuation line
As PEP8 says here. I think the standard is sometimes a bit vague. So this is open to the discussion how we want to handle that.
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.
Maybe I'll just do another round of formatting and push it as a proposal which we can then discuss?
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.
Maybe I'll just do another round of formatting and push it as a proposal which we can then discuss?
Sounds like an idea. Approved 👍
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 marked some things from the last rounds (mostly the hanging indent thingy). I don't know why you only changed it in one or two files, but now I made a comment everywhere where it occurs.
Also i left some other comments. Please look at them and if something seems odd, we can discuss about it.
src/InputParser.py
Outdated
self.board.getCoordinateNotationOfMove(move).lower() | ||
== notation.lower() |
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 think we discussed this before. Please indent this correct.
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.
It looked OK to me but sure, as you wish. This stuff is very subjective though and can easily be confused, plus 79 is a very strict limit, so if possible please suggest specific change here or even feel free to push it to this branch. Anyway, changing this one to:
if self.board.getCoordinateNotationOfMove(
move).lower() == notation.lower():
src/InputParser.py
Outdated
|
||
def getLegalMovesWithNotation(self, side: bool, short: bool = True) -> list[Move]: | ||
def getLegalMovesWithNotation( | ||
self, side: bool, short: bool = True |
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 think we discussed this before. Please indent this correct.
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.
src/InputParser.py
Outdated
type(move.piece) is Pawn | ||
and move.pieceToCapture | ||
and re.sub( | ||
'[1-8]', | ||
'', | ||
self.board.getCaptureNotation(move).replace('x', ''), | ||
) | ||
.lower() | ||
.endswith(shortNotation) |
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 think we discussed this before. Please indent this correct.
src/InputParser.py
Outdated
type(move.piece) is Pawn | ||
and move.pieceToCapture | ||
and self.board.getCaptureNotation(move) | ||
.replace('x', '') | ||
.lower() | ||
.endswith(shortNotation) |
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 think we discussed this before. Please indent this correct.
src/InputParser.py
Outdated
type(move.piece) is Pawn | ||
and not move.pieceToCapture | ||
and re.sub( | ||
'[1-8]', | ||
'', | ||
self.board.getCoordinateNotationOfMove(move), | ||
) | ||
.replace('=', '') | ||
.lower() | ||
.endswith(shortNotation) |
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 think we discussed this before. Please indent this correct.
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.
Again, it looked very clear to me, so please suggest a specific change. I'm changing it to the below for now, although I don't like it myself:
if type(move.piece) is Pawn and not move.pieceToCapture \
and re.sub(
'[1-8]', '', self.board.getCoordinateNotationOfMove(
move), ).replace('=', '').lower().endswith(
shortNotation):
src/Board.py
Outdated
len(self.getAllMovesLegal(self.currentSide)) == 0 | ||
and not self.isCheckmate() |
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.
This only needs to be indented one times, not two times.
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.
like this?
return len(self.getAllMovesLegal(self.currentSide)) == 0 \
and not self.isCheckmate()
src/Board.py
Outdated
fg_color | ||
+ bg_color | ||
+ DISPLAY_LOOKUP[piece.stringRep] | ||
+ ' ' | ||
+ attr(0) |
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.
This only need to be indented once, not two times.
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.
Like that?
pieceRep = fg_color + bg_color + DISPLAY_LOOKUP[
piece.stringRep] + ' ' + attr(0)
src/Board.py
Outdated
notation += str(move.specialMovePiece.stringRep) # type: ignore[attr-defined] | ||
|
||
notation += str( | ||
move.specialMovePiece.stringRep) # type: ignore[attr-defined] # noqa: E501 |
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.
The paranthese should be moved onto a separate line here.
src/Board.py
Outdated
notation += str(move.specialMovePiece.stringRep) # type: ignore[attr-defined, operator] | ||
|
||
notation += str( | ||
move.specialMovePiece.stringRep) # type: ignore[attr-defined, operator] # noqa: E501 |
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.
The paranthese should be moved onto a separate line here.
src/Board.py
Outdated
@@ -293,13 +316,16 @@ def getAlgebraicNotationOfMove(self, move: Move, short: bool = True) -> str: | |||
notation += self.positionToHumanCoord(move.newPos) | |||
|
|||
if move.promotion: | |||
notation += "=" + str(move.specialMovePiece.stringRep) # type: ignore[attr-defined] | |||
notation += '=' + str( | |||
move.specialMovePiece.stringRep) # type: ignore[attr-defined] # noqa: E501 |
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.
The paranthese should be moved onto a separate line here.
Round 3 pushed, although I'm still not sure i that's 100% what you expect. Feel free to suggest specific changes or push them directly if you wish, hopefully recent commit moves us in a good direction :) |
48633da
to
aa09c50
Compare
Remove dead code Make flake8 happy Add .python-version to .gitignore
aa09c50
to
ceb3cf6
Compare
Fixing the first two points of [#33 ]: