Skip to content

Commit

Permalink
Bump dependencies and replace black with ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme-Vasconcelos committed Nov 1, 2023
1 parent 52c9923 commit fb62f4a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: poetry run pytest -v

- name: Check format
run: poetry run black --check .
run: poetry run ruff format --check .

- name: Lint
run: poetry run ruff .
Expand Down
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"recommendations": [
"ms-python.python",
"charliermarsh.ruff",
"ms-python.mypy-type-checker",
"ms-python.black-formatter"
"ms-python.mypy-type-checker"
]
}
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.testing.pytestArgs": [
"."
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "strict",
"python.analysis.autoImportCompletions": true
"python.analysis.autoImportCompletions": true,
"mypy-type-checker.importStrategy": "fromEnvironment",
"ruff.importStrategy": "fromEnvironment"
}
10 changes: 6 additions & 4 deletions chessy/core/atkgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ def pawn_tables(self) -> tuple[list[set[c.Square]], list[set[c.Square]]]:
black_tables.append(set())
continue

for piece in c.Piece(c.Type.PAWN, c.Color.WHITE), c.Piece(
c.Type.PAWN, c.Color.BLACK
for piece in (
c.Piece(c.Type.PAWN, c.Color.WHITE),
c.Piece(c.Type.PAWN, c.Color.BLACK),
):
attacks = self._generate_pawn_attacks(sq, piece)
if piece.color == c.Color.WHITE:
Expand Down Expand Up @@ -130,8 +131,9 @@ def _generate_pawn_attacks(square: c.Square, piece: c.Piece) -> set[c.Square]:
}
side1 = direction_factor * 7
side2 = direction_factor * 9
directions = _DirectionalAdd(side1, prevented_files[side1]), _DirectionalAdd(
side2, prevented_files[side2]
directions = (
_DirectionalAdd(side1, prevented_files[side1]),
_DirectionalAdd(side2, prevented_files[side2]),
)

return _apply_multidirectional_add(directions, square, add_cycles_limit=1)
Expand Down
3 changes: 1 addition & 2 deletions chessy/core/movegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def append_maybe_promotion_move(move: c.Move) -> None:
assert (
# pylance wants us to be sure it is not none even though it was
# already not none the first time
pawn
is not None
pawn is not None
)
is_promotion = (
pawn.color == c.Color.WHITE and square.rank() == seventh_rank
Expand Down
124 changes: 22 additions & 102 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ python = "^3.11"

[tool.poetry.group.dev.dependencies]
mypy = "^1.6.1"
black = "^23.10.0"
ruff = "^0.1.0"
pytest = "^7.4.2"
ruff = "^0.1.3"
pytest = "^7.4.3"

[tool.poetry.scripts]
chessy = "chessy.core.__main__:main"
Expand Down Expand Up @@ -62,15 +61,15 @@ select = [
"PERF",
"RUF",
]
# Same as black.
line-length = 88
# Same as poetry.
target-version = "py311"
ignore = [
# Tests aside, I use asserts only for declaring states that are known to be true (preconditions, postconditions
# and invariants). If these states aren't met, it's a bug. Relying on buggy behavior is non-specified behavior,
# so it doesn't matter if the behavior varies between production and development.
"S101",
# `ruff format` says this rule can cause conflicts and recommends turning it off.
"ISC001",
]
unfixable = [
# Better DX: these fixes usually delete WIP code.
Expand Down
2 changes: 1 addition & 1 deletion tools/format_lint_test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Stop if any commands fail.
set -e

poetry run black .
poetry run ruff format .
poetry run ruff --fix .
poetry run mypy .
poetry run pytest

0 comments on commit fb62f4a

Please sign in to comment.