Skip to content

Commit 15f9765

Browse files
committed
Fix window even case not matching its type hints.
1 parent 746de2d commit 15f9765

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Changes relevant to the users of python-tcod are documented here.
44
This project adheres to [Semantic Versioning](https://semver.org/) since version `2.0.0`.
55

66
## [Unreleased]
7+
### Changed
8+
- Updated the case of window event types to match their type annotations.
9+
This may cause regressions. Run Mypy to check for ``[comparison-overlap]`` errors.
710

811
## [14.0.0] - 2022-12-09
912
### Added

tcod/event.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,7 @@ def __str__(self) -> str:
650650

651651

652652
class WindowEvent(Event):
653-
"""
654-
Attributes:
655-
type (str): A window event could mean various event types.
656-
"""
653+
"""A window event."""
657654

658655
type: Final[ # type: ignore[misc] # Narrowing final type.
659656
Literal[
@@ -675,12 +672,13 @@ class WindowEvent(Event):
675672
"WindowHitTest",
676673
]
677674
]
675+
"""The current window event. This can be one of various options."""
678676

679677
@classmethod
680678
def from_sdl_event(cls, sdl_event: Any) -> Union[WindowEvent, Undefined]:
681679
if sdl_event.window.event not in cls.__WINDOW_TYPES:
682680
return Undefined.from_sdl_event(sdl_event)
683-
event_type: Final = cls.__WINDOW_TYPES[sdl_event.window.event].upper()
681+
event_type: Final = cls.__WINDOW_TYPES[sdl_event.window.event]
684682
self: WindowEvent
685683
if sdl_event.window.event == lib.SDL_WINDOWEVENT_MOVED:
686684
self = WindowMoved(sdl_event.window.data1, sdl_event.window.data2)
@@ -720,12 +718,12 @@ def __repr__(self) -> str:
720718
class WindowMoved(WindowEvent):
721719
"""
722720
Attributes:
723-
type (str): Always "WINDOWMOVED".
724721
x (int): Movement on the x-axis.
725722
y (int): Movement on the y-axis.
726723
"""
727724

728725
type: Final[Literal["WINDOWMOVED"]] # type: ignore[assignment,misc]
726+
"""Always "WINDOWMOVED"."""
729727

730728
def __init__(self, x: int, y: int) -> None:
731729
super().__init__(None)
@@ -751,12 +749,12 @@ def __str__(self) -> str:
751749
class WindowResized(WindowEvent):
752750
"""
753751
Attributes:
754-
type (str): "WINDOWRESIZED" or "WINDOWSIZECHANGED"
755752
width (int): The current width of the window.
756753
height (int): The current height of the window.
757754
"""
758755

759756
type: Final[Literal["WINDOWRESIZED", "WINDOWSIZECHANGED"]] # type: ignore[assignment,misc]
757+
"""WINDOWRESIZED" or "WINDOWSIZECHANGED"""
760758

761759
def __init__(self, type: str, width: int, height: int) -> None:
762760
super().__init__(type)

0 commit comments

Comments
 (0)