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

Cleanup - fix flake8 errors and remove dead code #47

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

aaaandrzej
Copy link
Contributor

Fixing the first two points of [#33 ]:

  • Fix flake8 errors
  • removing dead code

.gitignore Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
mypy.ini Show resolved Hide resolved
src/Board.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ClasherKasten ClasherKasten left a 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.

.gitignore Outdated Show resolved Hide resolved
.flake8 Outdated Show resolved Hide resolved
src/Bishop.py Outdated
Comment on lines 29 to 32
for move in self.movesInDirectionFromPos(
currentPosition, direction, self.side
):
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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 👍

src/Board.py Outdated Show resolved Hide resolved
src/King.py Outdated Show resolved Hide resolved
src/Move.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ClasherKasten ClasherKasten left a 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.

Comment on lines 33 to 34
self.board.getCoordinateNotationOfMove(move).lower()
== notation.lower()
Copy link
Collaborator

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.

Copy link
Contributor Author

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():


def getLegalMovesWithNotation(self, side: bool, short: bool = True) -> list[Move]:
def getLegalMovesWithNotation(
self, side: bool, short: bool = True
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would you want to format this to fit the line length limit?

image

I can do

    def getLegalMovesWithNotation(
            self, side: bool, short: bool = True) -> list[Move]:

as

    def getLegalMovesWithNotation(
        self, side: bool, short: bool = True) -> list[Move]:

makes flake8 complain

Comment on lines 98 to 106
type(move.piece) is Pawn
and move.pieceToCapture
and re.sub(
'[1-8]',
'',
self.board.getCaptureNotation(move).replace('x', ''),
)
.lower()
.endswith(shortNotation)
Copy link
Collaborator

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.

Comment on lines 87 to 92
type(move.piece) is Pawn
and move.pieceToCapture
and self.board.getCaptureNotation(move)
.replace('x', '')
.lower()
.endswith(shortNotation)
Copy link
Collaborator

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.

Comment on lines 71 to 80
type(move.piece) is Pawn
and not move.pieceToCapture
and re.sub(
'[1-8]',
'',
self.board.getCoordinateNotationOfMove(move),
)
.replace('=', '')
.lower()
.endswith(shortNotation)
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Comment on lines 167 to 168
len(self.getAllMovesLegal(self.currentSide)) == 0
and not self.isCheckmate()
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Comment on lines 235 to 239
fg_color
+ bg_color
+ DISPLAY_LOOKUP[piece.stringRep]
+ ' '
+ attr(0)
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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.

@aaaandrzej
Copy link
Contributor Author

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 :)

Remove dead code

Make flake8 happy

Add .python-version to .gitignore
@ClasherKasten ClasherKasten merged commit c2d9ae9 into marcusbuffett:master Oct 12, 2022
@ClasherKasten ClasherKasten added the hacktoberfest-accepted Label for accepted PRs while Hacktoberfest label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Label for accepted PRs while Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants