Skip to content

Fix handler registration order in Scene#1642

Merged
JrooTJunior merged 3 commits intodev-3.xfrom
bugfix/1641-scene-handlers-ordering
Mar 1, 2025
Merged

Fix handler registration order in Scene#1642
JrooTJunior merged 3 commits intodev-3.xfrom
bugfix/1641-scene-handlers-ordering

Conversation

@JrooTJunior
Copy link
Member

Previously, Scene handlers were registered based on the sorted output of inspect.getmembers, causing incorrect execution order. Now, handlers are registered in the order they are defined in the class, ensuring reliable behavior and proper sequence when handling filters with varying specificity. Added test cases to validate the correct handler ordering.

Fixes: #1641

Previously, `Scene` handlers were registered based on the sorted output of `inspect.getmembers`, causing incorrect execution order. Now, handlers are registered in the order they are defined in the class, ensuring reliable behavior and proper sequence when handling filters with varying specificity. Added test cases to validate the correct handler ordering.
@github-actions github-actions bot added the 3.x Issue or PR for stable 3.x version label Feb 16, 2025
@github-actions
Copy link

✔️ Changelog found.

Thank you for adding a description of the changes

@codecov
Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e17c841) to head (04cec5a).
Report is 5 commits behind head on dev-3.x.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           dev-3.x     #1642   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          485       487    +2     
  Lines        12251     12320   +69     
=========================================
+ Hits         12251     12320   +69     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
aiogram/client/default.py 100.00% <100.00%> (ø)
aiogram/fsm/scene.py 100.00% <100.00%> (ø)
aiogram/utils/class_attrs_resolver.py 100.00% <100.00%> (ø)
aiogram/utils/dataclass.py 100.00% <100.00%> (ø)

Introduced `dataclass_kwargs` to ensure compatibility with different Python versions and modular attribute handling. Added utilities for resolving class attributes dynamically, enhancing flexibility with MRO-based resolvers. Updated tests to verify new features and ensure proper functionality across various scenarios.
@andrew000
Copy link
Contributor

Works correct in my project

@JrooTJunior JrooTJunior merged commit 8b4976b into dev-3.x Mar 1, 2025
23 checks passed
@JrooTJunior JrooTJunior deleted the bugfix/1641-scene-handlers-ordering branch March 1, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Issue or PR for stable 3.x version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Incorrect Ordering of Registered Handlers in Scene Object

2 participants