Skip to content

Commit aa7a0e7

Browse files
committed
Update pre-commit, fix Ruff and Mypy errors
1 parent 2b3d6fd commit aa7a0e7

File tree

10 files changed

+23
-31
lines changed

10 files changed

+23
-31
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: fix-byte-order-marker
1818
- id: detect-private-key
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.8.0
20+
rev: v0.11.2
2121
hooks:
2222
- id: ruff
2323
args: [--fix-only, --exit-non-zero-on-fix]

examples/samples_libtcodpy.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def render_colors(first, key, mouse):
220220
SAMPLE_SCREEN_HEIGHT - 1,
221221
libtcod.BKGND_MULTIPLY,
222222
libtcod.CENTER,
223-
"The Doryen library uses 24 bits " "colors, for both background and " "foreground.",
223+
"The Doryen library uses 24 bits colors, for both background and foreground.",
224224
)
225225

226226
if key.c == ord("f"):
@@ -270,10 +270,7 @@ def render_offscreen(first, key, mouse):
270270
SAMPLE_SCREEN_HEIGHT // 2,
271271
libtcod.BKGND_NONE,
272272
libtcod.CENTER,
273-
b"You can render to an offscreen "
274-
b"console and blit in on another "
275-
b"one, simulating alpha "
276-
b"transparency.",
273+
b"You can render to an offscreen console and blit in on another one, simulating alpha transparency.",
277274
)
278275
if first:
279276
libtcod.sys_set_fps(30)

examples/samples_tcod.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def print_banner(self) -> None:
163163
y=5,
164164
width=sample_console.width - 2,
165165
height=sample_console.height - 1,
166-
string="The Doryen library uses 24 bits colors, for both " "background and foreground.",
166+
string="The Doryen library uses 24 bits colors, for both background and foreground.",
167167
fg=WHITE,
168168
bg=GREY,
169169
bg_blend=libtcodpy.BKGND_MULTIPLY,
@@ -198,7 +198,7 @@ def __init__(self) -> None:
198198
2,
199199
sample_console.width // 2 - 2,
200200
sample_console.height // 2,
201-
"You can render to an offscreen console and blit in on another " "one, simulating alpha transparency.",
201+
"You can render to an offscreen console and blit in on another one, simulating alpha transparency.",
202202
fg=WHITE,
203203
bg=None,
204204
alignment=libtcodpy.CENTER,

examples/thread_jobs.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def run_test(
7777
for i in range(1, THREADS + 1):
7878
executor = concurrent.futures.ThreadPoolExecutor(i)
7979
multi_time = min(timeit.repeat(lambda: multi_func(executor, maps), number=1, repeat=REPEAT))
80-
print(f"{i} threads: {multi_time * 1000:.2f}ms, " f"{single_time / (multi_time * i) * 100:.2f}% efficiency")
80+
print(f"{i} threads: {multi_time * 1000:.2f}ms, {single_time / (multi_time * i) * 100:.2f}% efficiency")
8181

8282

8383
def main() -> None:
@@ -89,13 +89,10 @@ def main() -> None:
8989

9090
print(f"Python {sys.version}\n{platform.platform()}\n{platform.processor()}")
9191

92-
print(f"\nComputing field-of-view for " f"{len(maps)} empty {MAP_WIDTH}x{MAP_HEIGHT} maps.")
92+
print(f"\nComputing field-of-view for {len(maps)} empty {MAP_WIDTH}x{MAP_HEIGHT} maps.")
9393
run_test(maps, test_fov_single, test_fov_threads)
9494

95-
print(
96-
f"\nComputing AStar from corner to corner {len(maps)} times "
97-
f"on separate empty {MAP_WIDTH}x{MAP_HEIGHT} maps."
98-
)
95+
print(f"\nComputing AStar from corner to corner {len(maps)} times on separate empty {MAP_WIDTH}x{MAP_HEIGHT} maps.")
9996
run_test(maps, test_astar_single, test_astar_threads)
10097

10198

tcod/console.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def _fmt(string: str) -> bytes:
2929

3030
_root_console = None
3131

32-
rgba_graphic = np.dtype([("ch", np.intc), ("fg", "4B"), ("bg", "4B")])
32+
rgba_graphic: np.dtype[Any] = np.dtype([("ch", np.intc), ("fg", "4B"), ("bg", "4B")])
3333
"""A NumPy :any:`dtype` compatible with :any:`Console.rgba`.
3434
3535
This dtype is: ``np.dtype([("ch", np.intc), ("fg", "4B"), ("bg", "4B")])``
3636
3737
.. versionadded:: 12.3
3838
"""
3939

40-
rgb_graphic = np.dtype([("ch", np.intc), ("fg", "3B"), ("bg", "3B")])
40+
rgb_graphic: np.dtype[Any] = np.dtype([("ch", np.intc), ("fg", "3B"), ("bg", "3B")])
4141
"""A NumPy :any:`dtype` compatible with :any:`Console.rgb`.
4242
4343
This dtype is: ``np.dtype([("ch", np.intc), ("fg", "3B"), ("bg", "3B")])``
@@ -104,7 +104,7 @@ class Console:
104104
DTYPE = rgba_graphic
105105

106106
# A structured array type with the added "fg_rgb" and "bg_rgb" fields.
107-
_DTYPE_RGB = np.dtype(
107+
_DTYPE_RGB: np.dtype[Any] = np.dtype(
108108
{
109109
"names": ["ch", "fg", "bg"],
110110
"formats": [np.int32, "3u1", "3u1"],
@@ -955,7 +955,7 @@ def __setstate__(self, state: dict[str, Any]) -> None:
955955

956956
def __repr__(self) -> str:
957957
"""Return a string representation of this console."""
958-
return "tcod.console.Console(width=%i, height=%i, " "order=%r,buffer=\n%r)" % (
958+
return "tcod.console.Console(width=%i, height=%i, order=%r,buffer=\n%r)" % (
959959
self.width,
960960
self.height,
961961
self._order,

tcod/event.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def joystick(self) -> tcod.sdl.joystick.Joystick:
831831
return tcod.sdl.joystick.Joystick._from_instance_id(self.which)
832832

833833
def __repr__(self) -> str:
834-
return f"tcod.event.{self.__class__.__name__}" f"(type={self.type!r}, which={self.which})"
834+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, which={self.which})"
835835

836836
def __str__(self) -> str:
837837
prefix = super().__str__().strip("<>")
@@ -934,9 +934,7 @@ def from_sdl_event(cls, sdl_event: Any) -> JoystickHat:
934934
return cls("JOYHATMOTION", sdl_event.jhat.which, *_HAT_DIRECTIONS[sdl_event.jhat.hat])
935935

936936
def __repr__(self) -> str:
937-
return (
938-
f"tcod.event.{self.__class__.__name__}" f"(type={self.type!r}, which={self.which}, x={self.x}, y={self.y})"
939-
)
937+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, which={self.which}, x={self.x}, y={self.y})"
940938

941939
def __str__(self) -> str:
942940
prefix = super().__str__().strip("<>")
@@ -977,7 +975,7 @@ def from_sdl_event(cls, sdl_event: Any) -> JoystickButton:
977975
return cls(type, sdl_event.jbutton.which, sdl_event.jbutton.button)
978976

979977
def __repr__(self) -> str:
980-
return f"tcod.event.{self.__class__.__name__}" f"(type={self.type!r}, which={self.which}, button={self.button})"
978+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, which={self.which}, button={self.button})"
981979

982980
def __str__(self) -> str:
983981
prefix = super().__str__().strip("<>")
@@ -1032,7 +1030,7 @@ def controller(self) -> tcod.sdl.joystick.GameController:
10321030
return tcod.sdl.joystick.GameController._from_instance_id(self.which)
10331031

10341032
def __repr__(self) -> str:
1035-
return f"tcod.event.{self.__class__.__name__}" f"(type={self.type!r}, which={self.which})"
1033+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, which={self.which})"
10361034

10371035
def __str__(self) -> str:
10381036
prefix = super().__str__().strip("<>")

tcod/libtcodpy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def bsp_traverse_level_order(
697697
_bsp_traverse(node.level_order(), callback, userData)
698698

699699

700-
@deprecate("Iterate over nodes using " "'for n in node.inverted_level_order():' instead.")
700+
@deprecate("Iterate over nodes using 'for n in node.inverted_level_order():' instead.")
701701
def bsp_traverse_inverted_level_order(
702702
node: tcod.bsp.BSP,
703703
callback: Callable[[tcod.bsp.BSP, Any], None],
@@ -1863,7 +1863,7 @@ def console_delete(con: tcod.console.Console) -> None:
18631863
)
18641864
else:
18651865
warnings.warn(
1866-
"You no longer need to make this call, " "Console's are deleted when they go out of scope.",
1866+
"You no longer need to make this call, Console's are deleted when they go out of scope.",
18671867
DeprecationWarning,
18681868
stacklevel=2,
18691869
)
@@ -2398,7 +2398,7 @@ def heightmap_set_value(hm: NDArray[np.float32], x: int, y: int, value: float) -
23982398
"""
23992399
if hm.flags["C_CONTIGUOUS"]:
24002400
warnings.warn(
2401-
"Assign to this heightmap with hm[i,j] = value\n" "consider using order='F'",
2401+
"Assign to this heightmap with hm[i,j] = value\nconsider using order='F'",
24022402
DeprecationWarning,
24032403
stacklevel=2,
24042404
)
@@ -2847,7 +2847,7 @@ def heightmap_get_value(hm: NDArray[np.float32], x: int, y: int) -> float:
28472847
"""
28482848
if hm.flags["C_CONTIGUOUS"]:
28492849
warnings.warn(
2850-
"Get a value from this heightmap with hm[i,j]\n" "consider using order='F'",
2850+
"Get a value from this heightmap with hm[i,j]\nconsider using order='F'",
28512851
DeprecationWarning,
28522852
stacklevel=2,
28532853
)

tcod/noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __repr__(self) -> str:
9191
def __getattr__(name: str) -> Implementation:
9292
if name in Implementation.__members__:
9393
warnings.warn(
94-
f"'tcod.noise.{name}' is deprecated," f" use 'tcod.noise.Implementation.{name}' instead.",
94+
f"'tcod.noise.{name}' is deprecated, use 'tcod.noise.Implementation.{name}' instead.",
9595
FutureWarning,
9696
stacklevel=2,
9797
)

tcod/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(self, cost: Any, diagonal: float = 1.41) -> None:
171171

172172
if not hasattr(self.cost, "get_tcod_path_ffi"):
173173
assert not callable(self.cost), (
174-
"Any callback alone is missing shape information. " "Wrap your callback in tcod.path.EdgeCostCallback"
174+
"Any callback alone is missing shape information. Wrap your callback in tcod.path.EdgeCostCallback"
175175
)
176176
self.cost = NodeCostArray(self.cost)
177177

tests/test_console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_console_str() -> None:
112112
console.ch[:] = ord(".")
113113
with pytest.warns():
114114
console.print_(0, 0, "Test")
115-
assert str(console) == ("<Test......\n" " ..........>")
115+
assert str(console) == ("<Test......\n ..........>")
116116

117117

118118
def test_console_fortran_buffer() -> None:

0 commit comments

Comments
 (0)