pyriak` has undergone some more massive changes.
However, the general API is likely to be more stable in the future.
API Updates
- Subtype polymorphism completely removed (from components, states, and events/handlers)
- `subclasses()` and `strict_subclasses()` functions removed
- Removed `__call__` functionality from `Entity` and `StateManager`
- Use `__call__` instead of `__getitem__` for `EntityManager.components` and `QueryResult`
- `key_functions` (`EventKeyFunctions`) acts more like normal dict, removed `exists()` and `__call__` methods
- `bind()` can no longer be applied multiple times on one object/callback
- `Binding` class removed, `BindingWrapper` renamed to `Binding`
- Renamed `Binding` class contains binding info directly: `_event_type_`, `_callback_`, `_priority_`, `_keys_`
- `managers` subpackage removed/flattened: all manager files are in top-level package
- manager files renamed to have underscore before "manager" for readability
- `first()` function removed (as there are better ways to do things)
- `key_functions` (`EventKeyFunctions`) values can no longer be `None`
- Custom `__repr__()` method added to `Entity`
- `__weakref__` slot removed from `Entity`: entities are no longer weakly referenceable
- Removed `__setitem__` functionality from `Entity` and `StateManager`
- `Entity`/`StateManager` when removing by value, events contain original object instead of given one
- `process()` and `pump()` have positional-only arguments
- `SystemManager.process()` raises `RuntimeError` instead of `TypeError` when its space is `None`
Typing
- Removed overloads and return `Any` types in `QueryResult` to fix typing issues for `zip()`, `zip_entity()`
- `bind()` annotated return type is no longer `_Decorator` protocol type (multibinding removed)
- `clear()` methods return type explicitly annotated with `None`
Internal
- With no subtype polymorphism, greatly simplified source code
- `SystemManager._get_bindings()` returns `list[tuple[Binding, _EventHandler]]`
- Removed `SystemManager` `_lazy_bind()` and `_lazy_key_bind()` methods
- Reduced code size for many methods
- EventHandler events have base `_EventHandlerEvent`, and uses both binding and handler objects
- `EntityManager._component_types` renamed to `_type_cache`
- `SystemManager._get_handlers()` always returns a new list of handlers
- `_Components` class now has `__init__()` method
- All internal `type: ignore` comments have error codes
- `QueryResult` `__iter__` no longer set to `None`
- `space` module directly imports manager classes
- Small optimizations for query methods
- Line length limit lowered from 90 to 88 (88 is default in Ruff)
- Ruff target version is no longer set to `py311`
- Ignore rule "PERF203"
- TODO list updated
Other
- Added and updated docstrings for almost entire API (google style)
- Removed upper python limit "<4.0"
- Overall, improved performance and memory usage