Files
iris_x_hermes/gateway-plugin/ruff.toml
T
ARIA b8e756c3dd
CI / Gateway plugin tests (pull_request) Successful in 4m59s
CI / Kotlin tests (android host + desktop) (pull_request) Successful in 7m5s
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.
2026-08-24 20:55:00 +02:00

55 lines
2.1 KiB
TOML

# Lint config for the android gateway plugin.
#
# Run from the repo root (uses the hermes-agent venv's ruff):
# hermes-agent/.venv/bin/python -m ruff check gateway-plugin
#
# The rule set is deliberately broad (pycodestyle, pyflakes, isort, pyupgrade,
# bugbear, flake8-simplify, pylint, return, comprehensions).
#
# The pylint complexity ceilings (PLR0911/0912/0913/0915) are left at Ruff's
# built-in defaults (see [lint.pylint]). We deliberately do NOT raise them to
# "just above the current maxima": that ratchets the bar down every time code
# grows (LLM maintenance adds functions, it does not refactor them), so new
# complex code would silently pass. Instead, the handful of genuinely complex
# functions that already exist (frame builders that mirror 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.
line-length = 100
[lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"PL", # pylint
"RET", # flake8-return
"C4", # flake8-comprehensions
]
# The plugin intentionally defers hermes-runtime imports into function bodies
# (they are only available once the plugin is loaded inside the gateway, and
# some are optional/try-imported). Top-level import placement does not apply.
ignore = ["PLC0415"]
[lint.pylint]
# Ruff's built-in defaults. Existing outliers are noqa'd at the def line
# (search for `# noqa: PLR09`), not absorbed into a raised ceiling.
max-branches = 12
max-statements = 50
max-returns = 6
max-args = 5
[lint.per-file-ignores]
# The e2e / ws_probe drivers are assertion scripts: scenario numbers and
# control-flow sprawl are intentional and not worth refactoring.
"tests/**" = ["PLR2004", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PLW1510"]
# The device-admin CLI is a small operator script: argv length checks are
# its natural shape.
"tools/**" = ["PLR2004"]