Skip to content

Commit d841fe7

Browse files
committed
Apply Ruff auto fixes
1 parent a959202 commit d841fe7

File tree

9 files changed

+18
-34
lines changed

9 files changed

+18
-34
lines changed

examples/samples_tcod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def on_draw(self) -> None:
12951295
texture = np.roll(texture, -int_t, 1)
12961296
# replace new stretch of texture with new values
12971297
for v in range(RES_V - int_t, RES_V):
1298-
for u in range(0, RES_U):
1298+
for u in range(RES_U):
12991299
tex_v = (v + int_abs_t) / float(RES_V)
13001300
texture[u, v] = tcod.noise_get_fbm(noise2d, [u / float(RES_U), tex_v], 32.0) + tcod.noise_get_fbm(
13011301
noise2d, [1 - u / float(RES_U), tex_v], 32.0

examples/termbox/termbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def peek_event(self, timeout=0):
264264
else:
265265
uch = None
266266
"""
267-
pass # return (e.type, uch, e.key, e.mod, e.w, e.h, e.x, e.y)
267+
# return (e.type, uch, e.key, e.mod, e.w, e.h, e.x, e.y)
268268

269269
def poll_event(self):
270270
"""Wait for an event and return it.

tcod/event.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@
8383

8484
import enum
8585
import warnings
86-
from typing import Any, Callable, Generic, Iterator, Mapping, NamedTuple, TypeVar
86+
from typing import Any, Callable, Final, Generic, Iterator, Mapping, NamedTuple, TypeVar
8787

8888
import numpy as np
8989
from numpy.typing import NDArray
90-
from typing_extensions import Final, Literal
90+
from typing_extensions import Literal
9191

9292
import tcod.event_constants
9393
import tcod.sdl.joystick
@@ -796,12 +796,7 @@ def __init__(self, x: int, y: int) -> None:
796796
self.y = y
797797

798798
def __repr__(self) -> str:
799-
return "tcod.event.{}(type={!r}, x={!r}, y={!r})".format(
800-
self.__class__.__name__,
801-
self.type,
802-
self.x,
803-
self.y,
804-
)
799+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, x={self.x!r}, y={self.y!r})"
805800

806801
def __str__(self) -> str:
807802
return "<{}, x={!r}, y={!r})".format(
@@ -828,12 +823,7 @@ def __init__(self, type: str, width: int, height: int) -> None:
828823
self.height = height
829824

830825
def __repr__(self) -> str:
831-
return "tcod.event.{}(type={!r}, width={!r}, height={!r})".format(
832-
self.__class__.__name__,
833-
self.type,
834-
self.width,
835-
self.height,
836-
)
826+
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, width={self.width!r}, height={self.height!r})"
837827

838828
def __str__(self) -> str:
839829
return "<{}, width={!r}, height={!r})".format(

tcod/map.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def compute_fov(
137137
"""
138138
if not (0 <= x < self.width and 0 <= y < self.height):
139139
warnings.warn(
140-
"Index ({}, {}) is outside of this maps shape ({}, {})."
141-
"\nThis will raise an error in future versions.".format(x, y, self.width, self.height),
140+
f"Index ({x}, {y}) is outside of this maps shape ({self.width}, {self.height})."
141+
"\nThis will raise an error in future versions.",
142142
RuntimeWarning,
143143
stacklevel=2,
144144
)
@@ -239,8 +239,8 @@ def compute_fov(
239239
raise TypeError(msg)
240240
if not (0 <= pov[0] < transparency.shape[0] and 0 <= pov[1] < transparency.shape[1]):
241241
warnings.warn(
242-
"Given pov index {!r} is outside the array of shape {!r}."
243-
"\nThis will raise an error in future versions.".format(pov, transparency.shape),
242+
f"Given pov index {pov!r} is outside the array of shape {transparency.shape!r}."
243+
"\nThis will raise an error in future versions.",
244244
RuntimeWarning,
245245
stacklevel=2,
246246
)

tcod/path.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ def get_tcod_path_ffi(self) -> tuple[Any, Any, tuple[int, int]]:
8383
return self._CALLBACK_P, ffi.new_handle(self._userdata), self.shape
8484

8585
def __repr__(self) -> str:
86-
return "{}({!r}, shape={!r})".format(
87-
self.__class__.__name__,
88-
self._userdata,
89-
self.shape,
90-
)
86+
return f"{self.__class__.__name__}({self._userdata!r}, shape={self.shape!r})"
9187

9288

9389
class EdgeCostCallback(_EdgeCostFunc):

tcod/render.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929

3030
from __future__ import annotations
3131

32-
from typing import Any
33-
34-
from typing_extensions import Final
32+
from typing import Any, Final
3533

3634
import tcod.console
3735
import tcod.sdl.render

tcod/sdl/audio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
import threading
4949
import time
5050
from types import TracebackType
51-
from typing import Any, Callable, Hashable, Iterator
51+
from typing import Any, Callable, Final, Hashable, Iterator
5252

5353
import numpy as np
5454
from numpy.typing import ArrayLike, DTypeLike, NDArray
55-
from typing_extensions import Final, Literal, Self
55+
from typing_extensions import Literal, Self
5656

5757
import tcod.sdl.sys
5858
from tcod.cffi import ffi, lib

tcod/sdl/joystick.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from __future__ import annotations
66

77
import enum
8-
from typing import Any, ClassVar
8+
from typing import Any, ClassVar, Final
99
from weakref import WeakValueDictionary
1010

11-
from typing_extensions import Final, Literal
11+
from typing_extensions import Literal
1212

1313
import tcod.sdl.sys
1414
from tcod.cffi import ffi, lib

tcod/sdl/render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from __future__ import annotations
66

77
import enum
8-
from typing import Any
8+
from typing import Any, Final
99

1010
import numpy as np
1111
from numpy.typing import NDArray
12-
from typing_extensions import Final, Literal
12+
from typing_extensions import Literal
1313

1414
import tcod.sdl.video
1515
from tcod.cffi import ffi, lib

0 commit comments

Comments
 (0)