Skip to content

fix: Resolve all ruff lint errors and add CONFIG_SCHEMA#132

Merged
markus-lassfolk merged 9 commits intodevelopfrom
fix/lint-and-config
Mar 7, 2026
Merged

fix: Resolve all ruff lint errors and add CONFIG_SCHEMA#132
markus-lassfolk merged 9 commits intodevelopfrom
fix/lint-and-config

Conversation

@markus-lassfolk
Copy link
Copy Markdown
Owner

@markus-lassfolk markus-lassfolk commented Mar 7, 2026

Summary

Fix all 27 ruff lint errors and add missing CONFIG_SCHEMA for Home Assistant 2024.x compatibility.

Changes

__init__.py

  • Add CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) — prevents HA from logging warnings about missing config schema
  • Add import homeassistant.helpers.config_validation as cv
  • Add noqa: E402 for intentional late imports (after safety-net _lib_init_error_reporting call)

discovery.py

  • Add from typing import Any
  • Add type annotations to on_connect() and on_message() callbacks (ANN001/ANN202)

coordinator.py

  • Wrap long comment and expression to stay within 100-char limit (E501)

tests/test_init.py

  • Add -> None return type annotations to test functions (ANN201)
  • Replace assert False with raise AssertionError() (B011)
  • Auto-fix import sorting (I001)

Result

ruff check .All checks passed! (was 27 errors)


Note

Low Risk
Low risk: primarily lint/type/formatting changes plus a minimal CONFIG_SCHEMA addition and a safer (try/except) guard around disabling python-yarbo’s error reporting.

Overview
Adds CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) to the integration to satisfy HA’s expected config schema and updates __init__.py to disable python-yarbo’s library-level Sentry init via a try/except ImportError guard (with late imports annotated using # noqa: E402).

Cleans up remaining ruff violations across the integration (line wrapping, callback type annotations, minor simplifications) and updates tests to stub yarbo.error_reporting, mark DHCP discovery tests with @pytest.mark.allow_net_connect, and patch async_discover_endpoints to keep config-flow tests deterministic.

Written by Cursor Bugbot for commit 5e582e2. This will update automatically on new commits. Configure here.

- Add CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) for HA 2024.x compat
- Add type annotations to discovery.py callbacks (on_connect, on_message)
- Add return type annotations to test functions
- Replace assert False with raise AssertionError (B011)
- Fix line-too-long in coordinator.py (E501)
- Add noqa: E402 for intentional late imports in __init__.py
- Auto-fix import sorting (I001)

Ruff now passes with zero errors.
Copilot AI review requested due to automatic review settings March 7, 2026 09:01
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes all 27 ruff lint errors across the Yarbo Home Assistant integration codebase and adds the CONFIG_SCHEMA constant required for HA 2024.x compatibility.

Changes:

  • Adds CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) and corresponding cv import to __init__.py, along with noqa: E402 annotations on intentionally late imports
  • Adds type annotations (Any and -> None) to paho-mqtt callback functions in discovery.py and removes unnecessary noqa directives for rule sets (ARG, BLE) that aren't enabled
  • Wraps long lines in coordinator.py and fixes test function signatures, import ordering, and assert Falseraise AssertionError(...) in tests/test_init.py

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
custom_components/yarbo/__init__.py Added CONFIG_SCHEMA for HA compatibility, cv import, and noqa: E402 on late imports
custom_components/yarbo/discovery.py Added Any type annotations to MQTT callbacks, removed unnecessary noqa directives
custom_components/yarbo/coordinator.py Wrapped long comment and expression to stay within 100-char line limit
tests/test_init.py Added -> None return types, fixed import sorting, replaced assert False with raise AssertionError(...)

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Import changed from library to local, breaking safety net
    • Restored the import from yarbo.error_reporting (library) instead of .error_reporting (local module) so the safety net properly disables library-level Sentry auto-init.

cursoragent and others added 6 commits March 7, 2026 09:53
The import of init_error_reporting was incorrectly changed from the
library (yarbo.error_reporting) to the local module (.error_reporting).
This broke the safety net mechanism that disables library-level Sentry
auto-init in older versions of python-yarbo.

The _lib_init_error_reporting(enabled=False) call must invoke the
library's function, not the local one, to properly suppress Sentry
initialization in the python-yarbo package.
- Restore try/except import of yarbo.error_reporting in __init__.py to
  disable python-yarbo's Sentry auto-init (BugBot incorrectly removed it)
- Add yarbo.error_reporting stub to test conftest so CI can resolve the
  module (root cause: conftest stubs yarbo but didn't include error_reporting)
- Ensures GlitchTip catches errors from both HA integration (DSN /4) and
  python-yarbo library (DSN /2) without conflicts
… SocketBlockedError

The DHCP flow calls async_discover_endpoints() after _probe_robot_identity(),
which creates real network sockets. pytest-socket blocks these in tests.
Add the missing patch to test_dhcp_discovery_shows_confirm and
test_dhcp_confirm_then_mqtt_test_and_create_entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@markus-lassfolk markus-lassfolk merged commit 89448c8 into develop Mar 7, 2026
13 checks passed
@markus-lassfolk markus-lassfolk deleted the fix/lint-and-config branch March 7, 2026 10:29
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.

3 participants