Releases: aatle/pyriak
Releases · aatle/pyriak
0.4.1
This release features more API improvements and changes (based on observed pyriak usage), and also improved package documentation.
API Updates
tagclass()
function removed- All
add()
methods (Entity
,StateManager
,SystemManager
,EntityManager
) raiseValueError
if the object has already been added- New
update()
method that retains original behavior ofadd()
: remove old object if not equal to new object
- New
- Added
__setitem__
method toEntity
andStateManager
that has the behavior ofupdate()
ComponentRemoved
andEventHandlerRemoved
events are posted beforeEntityRemoved
andSystemRemoved
instead of after- Raise a
ValueError
instead ofKeyError
in some places bind()
decorator will now raiseTypeError
instead ofValueError
when keys are given for an event type with no key function
Typing
- The component, state, and event handler event types are now generic in their component/state/event type (invariant).
- The generic callback return type of
Binding
is now covariant instead of invariant - Generic event type of
Binding
integrated into type of_event_type_
attribute (type
->type[_T]
) - Removed unneeded field annotation in
SystemManager
Internal
_EventHandler
call only accepts(space, event)
arguments instead of(*args, **kwargs)
_EventHandler
is now generic in its event type- Event handler events post after they are bound/unbound instead of before
- Removed redundant, unused type variables in top-level module
Other
- Rewrote
README.md
file:- More formal and useful, added many sections
- Provides a guide on basic usage
- Badges for important info
- Removed the TODO list
- Improved PyPI package details: added PyPI classifiers and keywords
- Added more mypy checks/rules
- Updated docstrings of various things
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()
andstrict_subclasses()
functions removed- Removed
__call__
functionality fromEntity
andStateManager
- Use
__call__
instead of__getitem__
forEntityManager.components
andQueryResult
key_functions
(EventKeyFunctions
) acts more like normal dict, removedexists()
and__call__
methods
bind()
can no longer be applied multiple times on one object/callbackBinding
class removed,BindingWrapper
renamed toBinding
- 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 beNone
- Custom
__repr__()
method added toEntity
__weakref__
slot removed fromEntity
: entities are no longer weakly referenceable- Removed
__setitem__
functionality fromEntity
andStateManager
Entity
/StateManager
when removing by value, events contain original object instead of given oneprocess()
andpump()
have positional-only argumentsSystemManager.process()
raisesRuntimeError
instead ofTypeError
when its space isNone
Typing
- Removed overloads and return
Any
types inQueryResult
to fix typing issues forzip()
,zip_entity()
bind()
annotated return type is no longer_Decorator
protocol type (multibinding removed)clear()
methods return type explicitly annotated withNone
Internal
- With no subtype polymorphism, greatly simplified source code
SystemManager._get_bindings()
returnslist[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 toNone
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
andEntityManager
methodsentity_query()
,id_query()
QueryResult
is the only query result class
- New
QueryResult
method.zip_entity()
- Removed
query.py
,QueryResult
moved toentitymanager.py
- Removed
system.py
renamed tobind.py
System
type alias moved to top-level module
- Removed built-in event
SpaceCallback
SystemManager
no longer postsSpaceCallback
for system add/remove when no space available
- Removed built-in event
SendEvent
SystemManager.process()
method no longer takes optionalspace
argumenttagclass()
now returns a new class instead of mutating the argumenttagclass()
class instances are only equal if their types the same object, instead of subclasses- Removed
tagclass()
overload that created a new class from scratch liketype()
Typing
- Fixed typing issue when using
bind()
multiple times on one event handler BindingWrapper.__callback__
andBindingWrapper.__call__()
now have narrower type/signaturepyriak
__all__
list now includesEventQueue
type aliasentity.py
__all__
list now includesEntityId
QueryResult
entities
andtypes
properties have more abstract types- Typed
Space.process()
as returningbool
Internal
EntityManager
andEntity
query cache updates restructuredbind()
reuses a dedicated emptyfrozenset
when no keys are givenSpace.__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 forHashable
- pyriak no longer hooks into import system,
_importer.py
removed _BindingWrapper
is nowBindingWrapper
, and is no longer a temporary object on systems, refactored_Binding
class is now a namedtupleBinding
, and includesevent_type
- system event handler bindings are now a
tuple
instead of aMappingProxy
- query() methods raise
TypeError
instead ofValueError
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__
ofStateManager
andEntity
now only pop at most one state/componentSystemManager
no longer possibly getsevent_queue
from itsspace
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 ofAny
object
now used in place of someAny
occurrences- Type hinted
SpaceCallback
- Added overloads to
get()
andpop()
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__()
andget()
methods - Rewrote internal imports to be more direct
- Removed internal
_EventHandlerEvent
base class - Various default values now use internal
_SENTINEL
object, orNone
, instead ofEllipsis
Other
- Updated README
- Added dev dependencies
ruff
andmypy
topyproject.toml