Skip to content

Refactor: Introduce Union types for streamlined type handling#1649

Merged
JrooTJunior merged 4 commits intodev-3.xfrom
misc/1592-unions
Mar 8, 2025
Merged

Refactor: Introduce Union types for streamlined type handling#1649
JrooTJunior merged 4 commits intodev-3.xfrom
misc/1592-unions

Conversation

@JrooTJunior
Copy link
Member

Implemented Union types across various modules to consolidate and simplify type annotations. This change replaces repetitive union declarations with reusable Union aliases, improving code readability and maintainability. Updates applied to affected classes, methods, and imports accordingly.

Fixes: #1592

Implemented Union types across various modules to consolidate and simplify type annotations. This change replaces repetitive union declarations with reusable Union aliases, improving code readability and maintainability. Updates applied to affected classes, methods, and imports accordingly.
@github-actions github-actions bot added the 3.x Issue or PR for stable 3.x version label Mar 6, 2025
@codecov
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (843c1de) to head (4e4f417).
Report is 1 commits behind head on dev-3.x.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           dev-3.x     #1649    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          486       511    +25     
  Lines        12318     12524   +206     
==========================================
+ Hits         12318     12524   +206     
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/bot.py 100.00% <ø> (ø)
aiogram/methods/answer_inline_query.py 100.00% <100.00%> (ø)
aiogram/methods/answer_web_app_query.py 100.00% <100.00%> (ø)
aiogram/methods/approve_chat_join_request.py 100.00% <100.00%> (ø)
aiogram/methods/ban_chat_member.py 100.00% <100.00%> (ø)
aiogram/methods/ban_chat_sender_chat.py 100.00% <100.00%> (ø)
aiogram/methods/base.py 100.00% <ø> (ø)
aiogram/methods/close_forum_topic.py 100.00% <100.00%> (ø)
aiogram/methods/close_general_forum_topic.py 100.00% <100.00%> (ø)
aiogram/methods/copy_message.py 100.00% <100.00%> (ø)
... and 159 more
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replaced inline `Union` types with predefined aliases like `MediaUnion`, `ReplyMarkupUnion`, and `ChatIdUnion`. Simplifies type annotations, improves code readability, and reduces duplication. Added `media_union.py` for grouping related media types.
…nion

Replaced verbose type definitions of chat member and menu button unions with `ResultChatMemberUnion` and `ResultMenuButtonUnion` for improved readability and maintainability. Updated relevant methods, modules, and documentation to use the new type aliases consistently.
@aiogram aiogram deleted a comment from github-actions bot Mar 6, 2025
@JrooTJunior JrooTJunior marked this pull request as ready for review March 8, 2025 00:19
@JrooTJunior JrooTJunior merged commit cd4e811 into dev-3.x Mar 8, 2025
23 checks passed
@JrooTJunior JrooTJunior deleted the misc/1592-unions branch March 8, 2025 00:20
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.

answer_inline_query accepts an invariant type

1 participant