Skip to content

ci: tier 3 — enable remaining ruff groups (fixes + grandfathered noqas)#960

Draft
bluetoothbot wants to merge 2 commits into
uilibs:mainfrom
bluetoothbot:koan/fix-issue-958
Draft

ci: tier 3 — enable remaining ruff groups (fixes + grandfathered noqas)#960
bluetoothbot wants to merge 2 commits into
uilibs:mainfrom
bluetoothbot:koan/fix-issue-958

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Final Tier-3 slice of #872: adds the remaining aioesphomeapi-parity ruff
families to select (ANN, ARG, ASYNC, BLE, C90, EXE, NPY,
PT, SLF, TID, TRY), fixing the handful of real findings and
grandfathering the intentional ones with one-line # noqa. With #956 and
#957 merged the select mirrors aioesphomeapi and #872 can close.

Closes #958

Changes

  • Fix, then enable (no ignores): ARG002 reject-stub params renamed to
    _-prefixed; ARG001 unused args dropped/renamed; TRY300 success
    returns moved to else; TRY301 RTSPS-stream CLI helpers restructured so
    typer.Exit no longer raises inside the broad guard; TRY400
    logging.exception in JSON-decode paths; ANN001 SQLAlchemy connect
    listener annotated; PT018 composite TYPE_CHECKING assert split;
    EXE001 scripts/fetch_openapi.py + setup.py marked executable.
  • Ratchet: SLF001 (33), BLE001 (12), C901 (16), PT028 (4)
    grandfathered with one-line # noqa reasons. Private-API noqas disappear
    as that code is removed in the public-API migration.
  • Config: [tool.ruff.lint.mccabe] max-complexity = 10; tests/ exempt
    from the test-noise families (ANN/ARG/SLF/PT + ASYNC110/C901/
    TRY002), matching the existing tests per-file-ignore precedent.
  • Added CLI tests for the restructured create/delete RTSPS stream commands
    to keep 100% patch coverage on the touched lines.

Test plan

  • ruff check green; ruff format --check clean.
  • poetry run pytest green (the one unrelated test_public_schema_conformance
    failure also fails on main — it tracks the fetched OpenAPI spec version).
  • No behavioral changes beyond the intended small fixes; renames/noqas only
    otherwise.

Quality Report

Changes: 25 files changed, 256 insertions(+), 123 deletions(-)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan

Mechanical, behavior-preserving fixes so the SLF/BLE/ARG/C90/TRY/ANN/
ASYNC/PT/EXE families can be enabled cleanly:

- ARG002: rename unused base-contract params to _-prefixed (public
  device reject-stubs, user/types/api).
- ARG001: drop the unused _events no_input param and the anonymize_dict
  name param; rename unused callback params.
- TRY300: move success-path returns into else blocks.
- TRY301: restructure the camera RTSPS stream CLI helpers so the
  typer.Exit no longer raises inside the broad error guard.
- TRY400: use logging.exception in api JSON-decode error paths.
- ANN001: annotate the SQLAlchemy connect listener.
- PT018: split the composite TYPE_CHECKING assertion in bootstrap.
- EXE001: mark scripts/fetch_openapi.py and setup.py executable.

Add CLI tests covering the restructured create/delete RTSPS stream
commands (success/none/error paths) for 100% patch coverage.
Add the final aioesphomeapi-parity rule families to the ruff select:
ANN, ARG, ASYNC, BLE, C90, EXE, NPY, PT, SLF, TID, TRY. With uilibs#956 and
uilibs#957 this brings the select in line with aioesphomeapi (uilibs#872).

- Set [tool.ruff.lint.mccabe] max-complexity = 10 (ruff default, made
  explicit to match aioesphomeapi).
- Grandfather existing intentional cases with one-line # noqa:
  SLF001 (intra-package private access), BLE001 (broad resilience
  guards), C901 (complex private-API/bootstrap functions), and PT028
  (typer CLI commands named test_*). These shrink as the private API
  is removed in the public-API migration.
- Exempt tests/ from the test-noise families (ANN/ARG/SLF/PT plus
  ASYNC110/C901/TRY002), matching the existing tests per-file-ignore
  precedent.

The fix slice (ARG/TRY/ANN/EXE/PT018) landed in the previous commit.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d09a952-bbca-4ffe-97dd-f26c2e2b474d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq

codspeed-hq Bot commented Jun 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing bluetoothbot:koan/fix-issue-958 (76f5da6) with main (16f0cfe)

Open in CodSpeed

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38462% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/uiprotect/api.py 93.75% 1 Missing ⚠️
src/uiprotect/data/base.py 85.71% 1 Missing ⚠️
src/uiprotect/data/nvr.py 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/uiprotect/data/bootstrap.py 83.21% <100.00%> (ø)
src/uiprotect/data/devices.py 88.80% <100.00%> (ø)
src/uiprotect/data/public_bootstrap.py 100.00% <100.00%> (ø)
src/uiprotect/data/public_devices.py 100.00% <100.00%> (ø)
src/uiprotect/data/types.py 99.32% <100.00%> (ø)
src/uiprotect/data/user.py 96.01% <ø> (ø)
src/uiprotect/devices/dispatcher.py 100.00% <100.00%> (ø)
src/uiprotect/stream.py 100.00% <100.00%> (ø)
src/uiprotect/utils.py 95.16% <100.00%> (ø)
src/uiprotect/api.py 93.11% <93.75%> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tier 3 (#872): enable remaining ruff groups — SLF/BLE/ARG/C90/TRY/ANN/ASYNC/PT/EXE/NPY/TID

1 participant