Skip to content

Commit 61ce951

Browse files
committed
Silence several Ruff errors
1 parent 0684c08 commit 61ce951

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

tcod/event.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,11 @@ def _verify_tile_coordinates(xy: Point | None) -> Point:
174174
return Point(0, 0)
175175

176176

177-
_is_sdl_video_initialized = False
178-
179-
180177
def _init_sdl_video() -> None:
181178
"""Keyboard layout stuff needs SDL to be initialized first."""
182-
global _is_sdl_video_initialized
183-
if _is_sdl_video_initialized:
179+
if lib.SDL_WasInit(lib.SDL_INIT_VIDEO):
184180
return
185181
lib.SDL_InitSubSystem(lib.SDL_INIT_VIDEO)
186-
_is_sdl_video_initialized = True
187182

188183

189184
class Modifier(enum.IntFlag):
@@ -744,7 +739,7 @@ def from_sdl_event(cls, sdl_event: Any) -> WindowEvent | Undefined:
744739
def __repr__(self) -> str:
745740
return f"tcod.event.{self.__class__.__name__}(type={self.type!r})"
746741

747-
__WINDOW_TYPES = {
742+
__WINDOW_TYPES: Final = {
748743
lib.SDL_WINDOWEVENT_SHOWN: "WindowShown",
749744
lib.SDL_WINDOWEVENT_HIDDEN: "WindowHidden",
750745
lib.SDL_WINDOWEVENT_EXPOSED: "WindowExposed",
@@ -1592,7 +1587,9 @@ def handle_events(event: tcod.event.Event) -> None:
15921587
.. versionadded:: 13.4
15931588
"""
15941589
if callback in _event_watch_handles:
1595-
warnings.warn(f"{callback} is already an active event watcher, nothing was added.", RuntimeWarning)
1590+
warnings.warn(
1591+
f"{callback} is already an active event watcher, nothing was added.", RuntimeWarning, stacklevel=2
1592+
)
15961593
return callback
15971594
handle = _event_watch_handles[callback] = ffi.new_handle(callback)
15981595
lib.SDL_AddEventWatch(lib._sdl_event_watcher, handle)
@@ -1609,7 +1606,7 @@ def remove_watch(callback: Callable[[Event], None]) -> None:
16091606
.. versionadded:: 13.4
16101607
"""
16111608
if callback not in _event_watch_handles:
1612-
warnings.warn(f"{callback} is not an active event watcher, nothing was removed.", RuntimeWarning)
1609+
warnings.warn(f"{callback} is not an active event watcher, nothing was removed.", RuntimeWarning, stacklevel=2)
16131610
return
16141611
handle = _event_watch_handles[callback]
16151612
lib.SDL_DelEventWatch(lib._sdl_event_watcher, handle)
@@ -2813,7 +2810,7 @@ def __getattr__(name: str) -> int:
28132810
return value
28142811

28152812

2816-
__all__ = [
2813+
__all__ = [ # noqa: F405
28172814
"Modifier",
28182815
"Point",
28192816
"BUTTON_LEFT",

tcod/libtcodpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4285,7 +4285,7 @@ def __getattr__(name: str) -> Color:
42854285
raise AttributeError(msg) from None
42864286

42874287

4288-
__all__ = [
4288+
__all__ = [ # noqa: F405
42894289
"Color",
42904290
"Bsp",
42914291
"NB_FOV_ALGORITHMS",

0 commit comments

Comments
 (0)