Split adapter.py monolith into focused modules; restore Ruff complexity defaults (issue #12)
adapter.py was a 3,493-line monolith. Split it into focused modules with clear separation of responsibilities, bringing it down to ~857 lines: - Module-level helpers: hooks, classify, pickers, commands, setup, defaults, secrets - Frame-handler mixins: inbound, tool_frames, push_frames, media_frames, picker_frames, channel_frames, query_frames - mixin_base: IrisAdapterBase (declaration-only base for shared attrs) - adapter.py now holds only IrisAdapter (the composition of the 7 mixins + BasePlatformAdapter), register(), and test-facing re-exports The mixins come before BasePlatformAdapter in the MRO so their methods override the base; super() calls (e.g. send_image) still resolve to BasePlatformAdapter. No circular imports; dispatch.py and http_server.py (instance-method callers) are unaffected. Ruff complexity ceilings (PLR0911/0912/0913/0915) restored to Ruff's built-in defaults (12/50/6/5) instead of "just above the current maxima", which ratchets the bar down as code grows. The existing genuinely-complex functions (frame builders mirroring the wire schema, the QR matrix builder, the dispatch table) carry an explicit `# noqa: PLR09xx` marking them as reviewed, frozen exceptions; new code is held to the default ceilings. All 125 tests green (94 test_android + 31 test_android_http); no new ruff errors introduced.
This commit is contained in:
1 parent
7faaf2aa1c
commit
b8e756c3dd
26 files changed
+3101
-2775
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"""Shared base for the ``IrisAdapter`` mixin classes.
|
||||
|
||||
``adapter.IrisAdapter`` is assembled from several small mixin classes
|
||||
(``inbound``, ``tool_frames``, ``push_frames``, ...) plus the core state and
|
||||
lifecycle in ``adapter`` itself. Each mixin references instance attributes and
|
||||
helper methods that are defined in the core class or in a *sibling* mixin, so a
|
||||
type checker analysing one mixin in isolation cannot see them.
|
||||
|
||||
This base declares those shared names (as ``Any``) so static analysis resolves
|
||||
``self.<name>`` inside every mixin. The annotations carry no runtime effect;
|
||||
the real values are set in ``IrisAdapter.__init__`` and the real methods live
|
||||
in the core class / sibling mixins.
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
class IrisAdapterBase:
|
||||
"""Declaration-only base for the ``IrisAdapter`` mixins (see module doc)."""
|
||||
|
||||
# -- shared state (set in ``IrisAdapter.__init__``) -------------------
|
||||
_channels: Any
|
||||
_devices: Any
|
||||
_http_server: Any
|
||||
_media: Any
|
||||
_outbox: Any
|
||||
_push: Any
|
||||
_active_lane: Any
|
||||
_last_message_id: Any
|
||||
_last_push_at: Any
|
||||
_pending_push: Any
|
||||
_pending_pickers: Any
|
||||
_prune_notified_at: Any
|
||||
_typing_turns: Any
|
||||
home_channel: Any
|
||||
home_channel_name: Any
|
||||
|
||||
# -- shared helpers (core class or sibling mixins) --------------------
|
||||
_broadcast_both: Any
|
||||
_broadcast_or_log: Any
|
||||
_channel_name: Any
|
||||
_maybe_push: Any
|
||||
_offer_media: Any
|
||||
_parse_tool_line_or_block: Any
|
||||
_push_summary: Any
|
||||
_reply: Any
|
||||
_schedule_thread_title_upgrade: Any
|
||||
|
||||
# -- provided by ``BasePlatformAdapter`` / core -----------------------
|
||||
build_source: Any
|
||||
handle_message: Any
|
||||
send: Any
|
||||
send_image: Any
|
||||
send_slash_confirm: Any
|
||||
Reference in new issue
Block a user