diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd9a5d5..23876ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,8 @@ repos: -- repo: https://github.com/pycqa/isort - rev: 5.13.2 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.17.1 hooks: - - id: isort - additional_dependencies: [toml] -- repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black + - id: ruff-check + args: [--fix] + - id: ruff-format diff --git a/pqcli/mechanic.py b/pqcli/mechanic.py index 84bbe12..cdd98b5 100644 --- a/pqcli/mechanic.py +++ b/pqcli/mechanic.py @@ -923,7 +923,8 @@ def monster_task( result = monster.name lev = monster.level else: - # pick the monster out of so many random ones closest to the level we want + # pick the monster out of so many random ones closest to the level + # we want monster = unnamed_monster(data, level, iterations=5) result = monster.name lev = monster.level diff --git a/pqcli/ui/curses/__init__.py b/pqcli/ui/curses/__init__.py index 5c1331e..c03b566 100644 --- a/pqcli/ui/curses/__init__.py +++ b/pqcli/ui/curses/__init__.py @@ -143,10 +143,8 @@ class CursesUserInterface(BaseUserInterface): view.on_cancel += lambda: self._switch_to_create_char_race_view( player_name, race ) - view.on_confirm += ( - lambda class_: self._switch_to_create_char_stats_view( - player_name, race, class_ - ) + view.on_confirm += lambda class_: ( + self._switch_to_create_char_stats_view(player_name, race, class_) ) self._switch_view(view) diff --git a/pqcli/ui/curses/views/game_view/character_sheet_window.py b/pqcli/ui/curses/views/game_view/character_sheet_window.py index ebb1991..c05102d 100644 --- a/pqcli/ui/curses/views/game_view/character_sheet_window.py +++ b/pqcli/ui/curses/views/game_view/character_sheet_window.py @@ -61,6 +61,6 @@ class CharacterSheetWindow(Focusable, DataTableProgressBarWindow): self._cur_pos = self._player.exp_bar.position self._max_pos = self._player.exp_bar.max_ self._progress_title = ( - f"Experience ({self._max_pos-self._cur_pos:.0f} XP to go)" + f"Experience ({self._max_pos - self._cur_pos:.0f} XP to go)" ) self._render_progress_bar() diff --git a/pqcli/ui/curses/views/roster_view.py b/pqcli/ui/curses/views/roster_view.py index 4f4017a..a03e395 100644 --- a/pqcli/ui/curses/views/roster_view.py +++ b/pqcli/ui/curses/views/roster_view.py @@ -24,9 +24,7 @@ LOGO = """ █▄▄▀ █▀▀ ▄▀▀▄ ▄▀▀▄ █▀▀ ▄▀▀▄ ▄▀▀▀ ▄▀▀▀ █ █ █ █ ▄▀▀▄ ▄▀▀▀ ▀█▀ █ █ █ █ ▀▄▄█ █ █▀▀ ▀▀▄ ▀▀▄ █ ▌█ █ █ █▀▀ ▀▀▄ █ ▀ ▀ ▀▀ ▄▄▀ ▀ ▀▀ ▀▀▀ ▀▀▀ ▀▀▌ ▀▀ ▀▀ ▀▀▀ ▀ -""".strip( - "\n" -) +""".strip("\n") class MainMenu(Menu): diff --git a/pqcli/ui/curses/widgets/data_table.py b/pqcli/ui/curses/widgets/data_table.py index 65aa0df..6eef088 100644 --- a/pqcli/ui/curses/widgets/data_table.py +++ b/pqcli/ui/curses/widgets/data_table.py @@ -71,7 +71,8 @@ class DataTable(Scrollable): self._pad.addnstr(y, 0, row[0], min(len(row[0]), w)) # Determine the number of characters to write nwrite = min(len(row[1]), w - col2_x) - # Ensure we have enough columns, and we are writing more than zero + # Ensure we have enough columns, and we are writing more + # than zero if col2_x < w and nwrite > 0: self._pad.addnstr(y, col2_x, row[1], nwrite) if y == self._selected and has_colors(): diff --git a/pyproject.toml b/pyproject.toml index 7110435..17586b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,10 +42,11 @@ build-backend = "hatchling.build" [dependency-groups] dev = ["pre-commit>=2.16.0", "pytest>=8.0"] -[tool.black] +[tool.ruff] line-length = 79 -[tool.isort] -known_first_party = "pqcli" -multi_line_output = 3 -include_trailing_comma = true +[tool.ruff.lint] +select = ["E", "F", "W", "I"] + +[tool.ruff.lint.isort] +known-first-party = ["pqcli"] diff --git a/tests/test_mechanic.py b/tests/test_mechanic.py index 82094a1..a48ff75 100644 --- a/tests/test_mechanic.py +++ b/tests/test_mechanic.py @@ -129,7 +129,8 @@ def test_impressive_guy_formats() -> None: titles = "|".join(re.escape(title) for title in data.impressive_titles) races = "|".join(re.escape(plural(race.name)) for race in data.races) pattern = re.compile( - rf"the ({titles}) of the ({races})|({titles}) [A-Z][a-z]+ of [A-Z][a-z]+" + rf"the ({titles}) of the ({races})" + rf"|({titles}) [A-Z][a-z]+ of [A-Z][a-z]+" ) random.seed("guys") guys = [impressive_guy(data) for _ in range(200)]