Skip to content

Commit

Permalink
Apply Ruff auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HexDecimal committed Oct 25, 2023
1 parent a959202 commit d841fe7
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/samples_tcod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ def on_draw(self) -> None:
texture = np.roll(texture, -int_t, 1)
# replace new stretch of texture with new values
for v in range(RES_V - int_t, RES_V):
for u in range(0, RES_U):
for u in range(RES_U):
tex_v = (v + int_abs_t) / float(RES_V)
texture[u, v] = tcod.noise_get_fbm(noise2d, [u / float(RES_U), tex_v], 32.0) + tcod.noise_get_fbm(
noise2d, [1 - u / float(RES_U), tex_v], 32.0
Expand Down
2 changes: 1 addition & 1 deletion examples/termbox/termbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def peek_event(self, timeout=0):
else:
uch = None
"""
pass # return (e.type, uch, e.key, e.mod, e.w, e.h, e.x, e.y)
# return (e.type, uch, e.key, e.mod, e.w, e.h, e.x, e.y)

def poll_event(self):
"""Wait for an event and return it.
Expand Down
18 changes: 4 additions & 14 deletions tcod/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@

import enum
import warnings
from typing import Any, Callable, Generic, Iterator, Mapping, NamedTuple, TypeVar
from typing import Any, Callable, Final, Generic, Iterator, Mapping, NamedTuple, TypeVar

import numpy as np
from numpy.typing import NDArray
from typing_extensions import Final, Literal
from typing_extensions import Literal

import tcod.event_constants
import tcod.sdl.joystick
Expand Down Expand Up @@ -796,12 +796,7 @@ def __init__(self, x: int, y: int) -> None:
self.y = y

def __repr__(self) -> str:
return "tcod.event.{}(type={!r}, x={!r}, y={!r})".format(
self.__class__.__name__,
self.type,
self.x,
self.y,
)
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, x={self.x!r}, y={self.y!r})"

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

def __repr__(self) -> str:
return "tcod.event.{}(type={!r}, width={!r}, height={!r})".format(
self.__class__.__name__,
self.type,
self.width,
self.height,
)
return f"tcod.event.{self.__class__.__name__}(type={self.type!r}, width={self.width!r}, height={self.height!r})"

def __str__(self) -> str:
return "<{}, width={!r}, height={!r})".format(
Expand Down
8 changes: 4 additions & 4 deletions tcod/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def compute_fov(
"""
if not (0 <= x < self.width and 0 <= y < self.height):
warnings.warn(
"Index ({}, {}) is outside of this maps shape ({}, {})."
"\nThis will raise an error in future versions.".format(x, y, self.width, self.height),
f"Index ({x}, {y}) is outside of this maps shape ({self.width}, {self.height})."
"\nThis will raise an error in future versions.",
RuntimeWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -239,8 +239,8 @@ def compute_fov(
raise TypeError(msg)
if not (0 <= pov[0] < transparency.shape[0] and 0 <= pov[1] < transparency.shape[1]):
warnings.warn(
"Given pov index {!r} is outside the array of shape {!r}."
"\nThis will raise an error in future versions.".format(pov, transparency.shape),
f"Given pov index {pov!r} is outside the array of shape {transparency.shape!r}."
"\nThis will raise an error in future versions.",
RuntimeWarning,
stacklevel=2,
)
Expand Down
6 changes: 1 addition & 5 deletions tcod/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ def get_tcod_path_ffi(self) -> tuple[Any, Any, tuple[int, int]]:
return self._CALLBACK_P, ffi.new_handle(self._userdata), self.shape

def __repr__(self) -> str:
return "{}({!r}, shape={!r})".format(
self.__class__.__name__,
self._userdata,
self.shape,
)
return f"{self.__class__.__name__}({self._userdata!r}, shape={self.shape!r})"


class EdgeCostCallback(_EdgeCostFunc):
Expand Down
4 changes: 1 addition & 3 deletions tcod/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@

from __future__ import annotations

from typing import Any

from typing_extensions import Final
from typing import Any, Final

import tcod.console
import tcod.sdl.render
Expand Down
4 changes: 2 additions & 2 deletions tcod/sdl/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
import threading
import time
from types import TracebackType
from typing import Any, Callable, Hashable, Iterator
from typing import Any, Callable, Final, Hashable, Iterator

import numpy as np
from numpy.typing import ArrayLike, DTypeLike, NDArray
from typing_extensions import Final, Literal, Self
from typing_extensions import Literal, Self

import tcod.sdl.sys
from tcod.cffi import ffi, lib
Expand Down
4 changes: 2 additions & 2 deletions tcod/sdl/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from __future__ import annotations

import enum
from typing import Any, ClassVar
from typing import Any, ClassVar, Final
from weakref import WeakValueDictionary

from typing_extensions import Final, Literal
from typing_extensions import Literal

import tcod.sdl.sys
from tcod.cffi import ffi, lib
Expand Down
4 changes: 2 additions & 2 deletions tcod/sdl/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from __future__ import annotations

import enum
from typing import Any
from typing import Any, Final

import numpy as np
from numpy.typing import NDArray
from typing_extensions import Final, Literal
from typing_extensions import Literal

import tcod.sdl.video
from tcod.cffi import ffi, lib
Expand Down

0 comments on commit d841fe7

Please sign in to comment.