Pyriak

Latest version: v0.4.1

Safety actively analyzes 685838 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.4.0

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

0.3.1

API Updates
- Querying overhauled:
- Removed `Query` class
- Removed `Space` and `EntityManager` methods `entity_query()`, `id_query()`
- `QueryResult` is the only query result class
- New `QueryResult` method `.zip_entity()`
- Removed `query.py`, `QueryResult` moved to `entitymanager.py`
- `system.py` renamed to `bind.py`
- `System` type alias moved to top-level module
- Removed built-in event `SpaceCallback`
- `SystemManager` no longer posts `SpaceCallback` for system add/remove when no space available
- Removed built-in event `SendEvent`
- `SystemManager.process()` method no longer takes optional `space` argument
- `tagclass()` now returns a new class instead of mutating the argument
- `tagclass()` class instances are only equal if their types the same object, instead of subclasses
- Removed `tagclass()` overload that created a new class from scratch like `type()`

Typing
- Fixed typing issue when using `bind()` multiple times on one event handler
- `BindingWrapper.__callback__` and `BindingWrapper.__call__()` now have narrower type/signature
- `pyriak` `__all__` list now includes `EventQueue` type alias
- `entity.py` `__all__` list now includes `EntityId`
- `QueryResult` `entities` and `types` properties have more abstract types
- Typed `Space.process()` as returning `bool`

Internal
- `EntityManager` and `Entity` query cache updates restructured
- `bind()` reuses a dedicated empty `frozenset` when no keys are given
- `Space.__init__()` constructor assigns in a different order

Other
- Added license as a code comment to top-level module
- Added module docstring, package description, to top-level module
- Improved error message when a duplicate event type is bound to an event handler

0.3.0

API Updates
- `System` and `_SystemInfo` classes removed. `_system_ = System()` is no longer used
- Any hashable object is now a valid `System`, including classes. (Previously, only modules with `_system_` attribute were valid).
- `System` is now a TypeAlias for `Hashable`
- pyriak no longer hooks into import system, `_importer.py` removed
- `_BindingWrapper` is now `BindingWrapper`, and is no longer a temporary object on systems, refactored
- `_Binding` class is now a namedtuple `Binding`, and includes `event_type`
- system event handler bindings are now a `tuple` instead of a `MappingProxy`
- query() methods raise `TypeError` instead of `ValueError` when no component types given

Typing
- Typecasting into `System` is no longer necessary on most type checkers
- Removed `NoReturn` overloads from query methods and class
- Typed `QueryResult`
- Added mypy configuration in `pyproject.toml`
- Fixed `_SENTINEL` typing issue and other issues

Other
- Created github workflow for publishing
- Updated README

0.2.0

API Updates
- Removed `mro()` function
- Removed `Callback` class
- Removed `NoKey`, `NoKeyType`
- Added `first()` function to serve as a merge function
- Added `strict_subclasses()` function
- `__setitem__` of `StateManager` and `Entity` now only pop at most one state/component
- `SystemManager` no longer possibly gets `event_queue` from its `space`
- `Space.event_queue` is no longer a property that automatically sets the managers event queues
- Multikeys from key functions now must be any iterator

Typing
- Added `py.typed` file, making package type annotations public
- Events now typed with `object` instead of `Any`
- `object` now used in place of some `Any` occurrences
- Type hinted `SpaceCallback`
- Added overloads to `get()` and `pop()` methods to improve typing
- `bind()` now preserves return type of event handler callback
- Generally improved typing, successful mypy check

Internal
- `SystemManager` now has separate collections for keyed and unkeyed handlers
- Renamed `SystemManager._sorted_handlers()` to `_sort_handlers()`
- Increased performance of polymorphism-related `__getitem__()` and `get()` methods
- Rewrote internal imports to be more direct
- Removed internal `_EventHandlerEvent` base class
- Various default values now use internal `_SENTINEL` object, or `None`, instead of `Ellipsis`

Other
- Updated README
- Added dev dependencies `ruff` and `mypy` to `pyproject.toml`

0.1.0

First release of pyriak, mainly for personal use.
API and syntax is still under development.

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.