Skip to content

Commit 1ab50f7

Browse files
committed
Refactor event classes into dataclasses
Removes tons of boilerplate Improve docs by inheriting members in event subclasses Fix classes being undocumented due to being missing from `__all__` Begin to phase out `Event.type` attribute Hide linter warnings for unmaintained EventDispatch
1 parent 936b458 commit 1ab50f7

File tree

5 files changed

+310
-509
lines changed

5 files changed

+310
-509
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ This project adheres to [Semantic Versioning](https://semver.org/) since version
1010

1111
- `tcod.sdl.video.Window` now accepts an SDL WindowID.
1212

13+
### Changed
14+
15+
- Event classes are now more strict with attribute types
16+
- Event class initializers are keyword-only and no longer take a type parameter, with exceptions.
17+
Generally event class initialization is an internal process.
18+
- `MouseButtonEvent` no longer a subclass of `MouseState`.
19+
20+
### Deprecated
21+
22+
- `Event.type` is deprecated except for special cases such as `ControllerDevice`, `WindowEvent`, etc.
23+
- `MouseButtonEvent.state` is deprecated, replaced by the existing `.button` attribute.
24+
1325
## [20.1.0] - 2026-02-25
1426

1527
### Added

docs/tcod/event.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ SDL Event Handling ``tcod.event``
33

44
.. automodule:: tcod.event
55
:members:
6+
:inherited-members: object, int, str, tuple, Event
67
:member-order: bysource
78
:exclude-members:
89
KeySym, Scancode, Modifier, get, wait

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ license-files = [
2828
"libtcod/LIBTCOD-CREDITS.txt",
2929
]
3030
dependencies = [
31+
"attrs>=25.2.0",
3132
"cffi>=1.15",
3233
'numpy>=1.21.4; implementation_name != "pypy"',
3334
"typing_extensions>=4.12.2",

0 commit comments

Comments
 (0)