Skip to content

Commit 411a9d3

Browse files
committed
Update linters and config
Switch Ruff to ALL by default
1 parent 3d9a1e6 commit 411a9d3

File tree

8 files changed

+27
-39
lines changed

8 files changed

+27
-39
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3+
ci:
4+
autoupdate_schedule: quarterly
35
repos:
46
- repo: https://github.com/pre-commit/pre-commit-hooks
57
rev: v4.6.0
@@ -15,7 +17,7 @@ repos:
1517
- id: fix-byte-order-marker
1618
- id: detect-private-key
1719
- repo: https://github.com/astral-sh/ruff-pre-commit
18-
rev: v0.4.10
20+
rev: v0.6.7
1921
hooks:
2022
- id: ruff
2123
args: [--fix, --exit-non-zero-on-fix]

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"configurations": [
77
{
88
"name": "Python: Module",
9-
"type": "python",
9+
"type": "debugpy",
1010
"request": "launch",
1111
"module": "main",
1212
"justMyCode": true

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"editor.defaultFormatter": "charliermarsh.ruff"
1414
},
1515
"cSpell.words": [
16+
"autoupdate",
1617
"blit",
1718
"isort",
1819
"PAGEDOWN",

game/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Global constants are stored here."""
22

3+
from __future__ import annotations
4+
35
from typing import Final
46

57
from tcod.event import KeySym

game/menus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MenuItem(Protocol):
2323
def on_event(self, event: tcod.event.Event) -> StateResult:
2424
"""Handle events passed to the menu item."""
2525

26-
def on_draw(self, console: tcod.console.Console, x: int, y: int, highlight: bool) -> None:
26+
def on_draw(self, console: tcod.console.Console, x: int, y: int, *, highlight: bool) -> None:
2727
"""Draw is item at the given position."""
2828

2929

@@ -44,7 +44,7 @@ def on_event(self, event: tcod.event.Event) -> StateResult:
4444
case _:
4545
return None
4646

47-
def on_draw(self, console: tcod.console.Console, x: int, y: int, highlight: bool) -> None:
47+
def on_draw(self, console: tcod.console.Console, x: int, y: int, *, highlight: bool) -> None:
4848
"""Render this items label."""
4949
console.print(x, y, self.label, fg=(255, 255, 255), bg=(64, 64, 64) if highlight else (0, 0, 0))
5050

@@ -62,7 +62,7 @@ def on_event(self, event: tcod.event.Event) -> StateResult:
6262
"""Handle events for menus."""
6363
match event:
6464
case tcod.event.Quit():
65-
raise SystemExit()
65+
raise SystemExit
6666
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
6767
dx, dy = DIRECTION_KEYS[sym]
6868
if dx != 0 or dy == 0:

game/state_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import tcod.console
6+
import tcod.event
67

78
import g
89
from game.state import Pop, Push, Reset, State, StateResult
@@ -50,7 +51,7 @@ def get_previous_state(state: State) -> State | None:
5051
return g.states[current_index - 1] if current_index > 0 else None
5152

5253

53-
def draw_previous_state(state: State, console: tcod.console.Console, dim: bool = True) -> None:
54+
def draw_previous_state(state: State, console: tcod.console.Console, *, dim: bool = True) -> None:
5455
"""Draw previous states, optionally dimming all but the active state."""
5556
prev_state = get_previous_state(state)
5657
if prev_state is None:

game/states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def on_event(self, event: tcod.event.Event) -> StateResult:
2626
(player,) = g.world.Q.all_of(tags=[IsPlayer])
2727
match event:
2828
case tcod.event.Quit():
29-
raise SystemExit()
29+
raise SystemExit
3030
case tcod.event.KeyDown(sym=sym) if sym in DIRECTION_KEYS:
3131
player.components[Position] += DIRECTION_KEYS[sym]
3232
# Auto pickup gold
@@ -89,4 +89,4 @@ def new_game() -> StateResult:
8989
@staticmethod
9090
def quit() -> StateResult:
9191
"""Close the program."""
92-
raise SystemExit()
92+
raise SystemExit

pyproject.toml

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,24 @@ line-length = 120
2222
target-version = "py311"
2323

2424
[tool.ruff.lint]
25-
select = [
26-
"C90", # mccabe
27-
"D", # pydocstyle
28-
"E", # pycodestyle
29-
"W", # pycodestyle
30-
"F", # Pyflakes
31-
"I", # isort
32-
"UP", # pyupgrade
33-
"YTT", # flake8-2020
34-
"ANN", # flake8-annotations
35-
"S", # flake8-bandit
36-
"B", # flake8-bugbear
37-
"C4", # flake8-comprehensions
38-
"DTZ", # flake8-datetimez
39-
"EM", # flake8-errmsg
40-
"EXE", # flake8-executable
41-
"FA", # flake8-future-annotations
42-
"RET", # flake8-return
43-
"ICN", # flake8-import-conventions
44-
"PIE", # flake8-pie
45-
"PT", # flake8-pytest-style
46-
"SIM", # flake8-simplify
47-
"PTH", # flake8-use-pathlib
48-
"PL", # Pylint
49-
"TRY", # tryceratops
50-
"RUF", # NumPy-specific rules
51-
"G", # flake8-logging-format
52-
]
25+
select = ["ALL"]
5326
ignore = [
54-
"E501", # line-too-long
55-
"S101", # assert
5627
"ANN101", # missing-type-self
5728
"ANN102", # missing-type-cls
58-
"S311", # suspicious-non-cryptographic-random-usage
29+
"COM", # flake8-commas
30+
"E501", # line-too-long
31+
"ISC001", # single-line-implicit-string-concatenation
5932
"PLR0913", # too-many-arguments
33+
"S101", # assert
34+
"S311", # suspicious-non-cryptographic-random-usage
35+
"T20", # flake8-print
36+
"TCH001", # typing-only-first-party-import
37+
"TCH002", # typing-only-third-party-import
38+
"TCH003", # typing-only-standard-library-import
6039
]
6140

41+
[tool.ruff.lint.isort]
42+
required-imports = ["from __future__ import annotations"]
43+
6244
[tool.ruff.lint.pydocstyle] # https://docs.astral.sh/ruff/settings/#lintpydocstyle
6345
convention = "google"

0 commit comments

Comments
 (0)