Skip to content

Conversation

@CoMPaTech
Copy link
Member

@CoMPaTech CoMPaTech commented Jun 18, 2025

Note: not using the custom-component in python-plug wise yet

Re-instating ruff (though handicapped, see notes in #171 as a todo list to clean up in pyproject.toml and not touchline mypy yet (that still is disabled): as discussed on discord

⚠️ Requires developers to clean your local venv and re-run the setup-scripts (i.e. moving towards uv again)

Summary by CodeRabbit

  • Chores

    • Modernized and streamlined development environment setup scripts for improved reliability and flexibility.
    • Updated pre-commit configuration: re-enabled and expanded code linting and formatting hooks, added new tools (Ruff, Biome, ShellCheck), and improved naming and arguments for clarity.
    • Integrated Biome and Ruff linters into automated checks and workflows.
    • Removed obsolete scripts and configuration files to reduce maintenance overhead.
    • Updated documentation to reflect changes in tooling and maintenance practices.
  • Refactor

    • Unified and enhanced linting, formatting, and testing tool configurations for a more consistent developer experience.

@CoMPaTech CoMPaTech added enhancement New feature or request dependencies Pull requests that update a dependency file pre-commit labels Jun 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 18, 2025

Warning

Rate limit exceeded

@CoMPaTech has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9247974 and afa96a6.

📒 Files selected for processing (12)
  • .github/workflows/verify.yml (7 hunks)
  • .pre-commit-config.yaml (2 hunks)
  • CHANGELOG.md (1 hunks)
  • pyproject.toml (8 hunks)
  • scripts/complexity.sh (1 hunks)
  • scripts/pre-commit.sh (0 hunks)
  • scripts/python-venv.sh (0 hunks)
  • scripts/run-in-env.sh (1 hunks)
  • scripts/setup.sh (1 hunks)
  • scripts/setup_test.sh (1 hunks)
  • scripts/tests_and_coverage.sh (2 hunks)
  • setup.cfg (0 hunks)

Walkthrough

This update modernizes and consolidates development tooling, focusing on linting, formatting, and environment setup. It refactors shell scripts for improved virtual environment handling, replaces and expands pre-commit hooks, updates CI workflows to use uv, re-enables and configures ruff and biome linters, and removes or merges redundant configuration files.

Changes

File(s) Change Summary
.github/workflows/verify.yml Refactored to use uv for pip commands, enabled Ruff and Biome linting, changed Ruff commands, updated secret usage, and disabled pull_request trigger.
.pre-commit-config.yaml Re-enabled and expanded hooks, added explicit naming, improved arguments, added biome and shellcheck hooks, and reorganized local hooks.
CHANGELOG.md Added entry noting Ruff linter reinstatement and pre-commit cloud deprecation.
pyproject.toml Updated linting and formatting tool configs, expanded disables, unified settings for pylint, ruff, pytest, and mypy, and removed black/isort configs.
scripts/complexity.sh, scripts/run-in-env.sh, scripts/setup.sh, scripts/setup_test.sh, scripts/tests_and_coverage.sh Refactored virtual environment setup/activation logic, removed dependency on external scripts, improved error handling, and added/updated dependency installation and linting steps.
scripts/pre-commit.sh, scripts/python-venv.sh, setup.cfg Deleted obsolete scripts and configuration files related to pre-commit checks and virtual environment setup.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Shell as Shell Script
    participant VEnv as Virtual Env
    participant Lint as Linter (ruff/biome)
    participant CI as GitHub Actions

    Dev->>Shell: Run setup/test/lint script
    Shell->>VEnv: Check/activate/create venv (uv or python3)
    Shell->>Shell: Install dependencies (uv pip install)
    Shell->>Lint: Run ruff/biome/pylint/pre-commit
    Lint-->>Shell: Linting results
    Shell-->>Dev: Output results

    Dev->>CI: Push/PR triggers workflow
    CI->>Shell: Setup environment (uv, pip, etc.)
    CI->>Lint: Run ruff/biome checks
    Lint-->>CI: Linting results
    CI-->>Dev: CI status/reports
Loading

Possibly related PRs

  • Catch up #170: Updates .github/workflows/verify.yml with similar changes to cache versioning, pip install commands, and Ruff linting, indicating a directly related update to CI workflows.

Suggested reviewers

  • dirixmjm

Poem

In the warren where code bunnies dwell,
We tidied our scripts and configs as well.
Ruff and Biome now hop in line,
With uv, our installs are mighty fine.
Old scripts retired, new hooks in place—
The codebase is spruced for a hoppier race!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch ruff

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (8)
CHANGELOG.md (1)

5-6: Include PR reference in changelog entry.
The new maintenance entry doesn't reference the PR number/link. Please prepend the PR link similar to the other entries, e.g.:
- PR [#263](https://github.com/plugwise/python-plugwise-usb/pull/263): Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (leveraging renovate)

scripts/complexity.sh (1)

6-20: Reduce redundancy in my_path assignment.
my_path is set twice via git rev-parse; the second assignment (line 11) is unnecessary.

Consider removing the duplicate assignment so the script reuses the initial my_path.

-  my_path=$(git rev-parse --show-toplevel)
+  # reuse existing my_path from above
scripts/setup.sh (2)

2-3: Optional: Clarify provenance comment
The copy notice and set -e usage are clear and appropriate. Consider specifying the original HA-core version or date more precisely if provenance tracking is required.


19-20: Refactor long pip install command
This single uv pip install invocation works but is hard to read. Consider splitting it over multiple lines with backslashes for maintainability.

.github/workflows/verify.yml (1)

160-164: Introduce Biome linting in commitcheck
Adding a Biome step is aligned with .pre-commit-config.yaml. Consider caching the downloaded biome binary to speed up runs.

You might add a cache action on ./tmp/biome to avoid re-downloading each run.

scripts/setup_test.sh (1)

7-15: Create venv via uv when available
Using uv venv venv if present, otherwise falling back to python3 -m venv, is robust.

You could simplify the command-existence check:

- if [ -x "$(command -v uv)" ]; then
+ if command -v uv >/dev/null 2>&1; then

to avoid testing -x on a symlink.

scripts/tests_and_coverage.sh (1)

5-7: Guard against undefined OSTYPE
Initializing OSTYPE avoids unbound-var errors under set -u. Using ${OSTYPE:-} is more idiomatic:

- OSTYPE="${OSTYPE-}"
+ OSTYPE="${OSTYPE:-}"
pyproject.toml (1)

112-359: Bulk import of Pylint disables from Core
This extensive disable list mirrors Core’s configuration. Consider pruning entries as code evolves.

You may revisit and remove entries for rules already covered by Ruff or Biome over time.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9247974 and 403b2c5.

📒 Files selected for processing (41)
  • .github/workflows/verify.yml (7 hunks)
  • .pre-commit-config.yaml (3 hunks)
  • CHANGELOG.md (1 hunks)
  • plugwise_usb/__init__.py (7 hunks)
  • plugwise_usb/api.py (1 hunks)
  • plugwise_usb/connection/__init__.py (1 hunks)
  • plugwise_usb/connection/queue.py (3 hunks)
  • plugwise_usb/connection/receiver.py (1 hunks)
  • plugwise_usb/connection/sender.py (4 hunks)
  • plugwise_usb/constants.py (1 hunks)
  • plugwise_usb/helpers/cache.py (4 hunks)
  • plugwise_usb/helpers/util.py (2 hunks)
  • plugwise_usb/messages/__init__.py (1 hunks)
  • plugwise_usb/messages/properties.py (2 hunks)
  • plugwise_usb/messages/requests.py (2 hunks)
  • plugwise_usb/messages/responses.py (2 hunks)
  • plugwise_usb/network/__init__.py (2 hunks)
  • plugwise_usb/network/cache.py (1 hunks)
  • plugwise_usb/nodes/celsius.py (1 hunks)
  • plugwise_usb/nodes/circle.py (2 hunks)
  • plugwise_usb/nodes/circle_plus.py (2 hunks)
  • plugwise_usb/nodes/helpers/__init__.py (1 hunks)
  • plugwise_usb/nodes/helpers/counter.py (3 hunks)
  • plugwise_usb/nodes/helpers/pulses.py (4 hunks)
  • plugwise_usb/nodes/helpers/subscription.py (2 hunks)
  • plugwise_usb/nodes/node.py (5 hunks)
  • plugwise_usb/nodes/scan.py (5 hunks)
  • plugwise_usb/nodes/sed.py (1 hunks)
  • plugwise_usb/nodes/sense.py (2 hunks)
  • plugwise_usb/nodes/stealth.py (1 hunks)
  • plugwise_usb/nodes/switch.py (3 hunks)
  • pyproject.toml (8 hunks)
  • scripts/complexity.sh (1 hunks)
  • scripts/python-venv.sh (0 hunks)
  • scripts/run-in-env.sh (1 hunks)
  • scripts/setup.sh (1 hunks)
  • scripts/setup_test.sh (1 hunks)
  • scripts/tests_and_coverage.sh (2 hunks)
  • setup.cfg (0 hunks)
  • tests/stick_test_data.py (1 hunks)
  • tests/test_usb.py (3 hunks)
💤 Files with no reviewable changes (2)
  • setup.cfg
  • scripts/python-venv.sh
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/verify.yml

104-104: shellcheck reported issue in this script: SC2086:info:5:83: Double quote to prevent globbing and word splitting

(shellcheck)


104-104: shellcheck reported issue in this script: SC2086:info:6:14: Double quote to prevent globbing and word splitting

(shellcheck)


104-104: shellcheck reported issue in this script: SC2086:info:8:17: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (120)
plugwise_usb/messages/properties.py (2)

12-14: Formatting: Multiline assignment for DESERIALIZE_ERROR enhances readability
Splitting the error message across lines improves maintainability without altering functionality.


396-398: Simplify zero handling in LogAddr.deserialize
Directly assigning 0 removes an unnecessary cast while preserving behavior.

plugwise_usb/constants.py (1)

2-2: Approve formatting update.
Whitespace-only change: added blank line after the module docstring to improve readability and maintain consistent style.

plugwise_usb/nodes/celsius.py (1)

5-5: Approve formatting update.
Added blank line after the module docstring for consistency with style guidelines. No functional change.

plugwise_usb/messages/__init__.py (1)

22-22: Approve formatting update.
Inserted a newline between the Priority enum and the PlugwiseMessage class to enhance readability and maintain code style consistency.

plugwise_usb/nodes/stealth.py (1)

2-2: Approve formatting update.
Blank line added after the module docstring to align with the project's whitespace conventions.

plugwise_usb/connection/receiver.py (1)

516-516: Approve formatting update.
Trailing newline inserted before the endregion marker for consistency. No behavioral impact.

plugwise_usb/nodes/sense.py (2)

56-56: Whitespace-only change in debug log is fine
No behavioral impact; keeps logging consistent.


96-104: Region marker spacing improves readability
Purely stylistic; no issues.

plugwise_usb/network/cache.py (1)

37-39: Multiline string composition is clearer
Parentheses avoid line-length warnings while keeping logic intact.

plugwise_usb/nodes/helpers/__init__.py (1)

28-34: Added blank lines for visual separation
Makes the decorator easier to scan; no functional change.

plugwise_usb/connection/sender.py (4)

51-51: Removal of redundant blank line is harmless
Keeps section compact.


82-85: Wrapped long debug log across lines
Enhances readability without touching logic.


111-115: Consistent multiline formatting for debug statement
Good stylistic alignment with earlier change.


129-131: Follow-up debug log formatting looks good
No concerns.

plugwise_usb/nodes/helpers/subscription.py (2)

23-23: Trimmed extra blank line after class docstring
Keeps class definition tight; fine.


61-63: Line-wrapped append call for clarity
Readability improvement only.

plugwise_usb/api.py (2)

236-236: Consistent blank line before SenseStatistics dataclass.

This formatting aligns with project style and improves readability.


244-244: Add blank line before PlugwiseNode protocol declaration.

Ensures logical grouping and visual separation of API definitions.

plugwise_usb/nodes/sed.py (1)

241-242: Remove extraneous blank line after return False.

Formatting-only change; no impact on logic.

plugwise_usb/nodes/circle.py (2)

503-503: Reformat _LOGGER.debug call for energy log slot.

Consolidated the multiline logging invocation for consistency.


991-991: Normalize spacing in _node_info_load_from_cache debug call.

Minor formatting tweak; no functional changes.

tests/stick_test_data.py (2)

63-64: Formatting tweak looks good

The added space in the hw_ver comment improves readability and complies with the new linting rules.


67-72: Colon-spacing nit only – OK

The extra space after the dictionary key marker is purely stylistic and has no behavioural impact.

plugwise_usb/helpers/util.py (2)

2-2: Blank line after doc-string – fine

No functional impact; keeps Ruff happy.


25-26: Type-hint spacing aligned with PEP 604

The new signature tuple[str | None, str] improves readability without altering behaviour.

plugwise_usb/network/__init__.py (3)

261-263: Logging re-formatted – clear & lazy-formatted

The multi-line _LOGGER.debug keeps the format-string/args style intact, so there’s no overhead from f-strings.


561-564: Validation message wrapped – no logic change

Only the error text was re-wrapped; validation logic remains identical.


565-567: Debug message split – consistent style

Same content, just reflowed; all good.

plugwise_usb/connection/__init__.py (1)

212-220: One-liner request construction – still compliant

Collapsing the request instantiation onto one line doesn’t affect readability or complexity here.

plugwise_usb/connection/queue.py (3)

78-80: Trailing-whitespace cleanup – OK


106-108: Lower log-level kept for expected ping timeouts

Splitting the debug statement is fine; behaviour unchanged.


151-154: Queue-depth warning wrapped – clear

Reformatted logging only; logic intact.

plugwise_usb/messages/responses.py (5)

781-781: Formatting: Simplify default log_data entry
The else fallback now explicitly assigns (None, None) for clarity and consistency.


785-785: Formatting: Simplify default log_data entry
Consistent fallback for the second log entry maintains readability.


789-789: Formatting: Simplify default log_data entry
Consistent fallback for the third log entry maintains readability.


793-793: Formatting: Simplify default log_data entry
Consistent fallback for the fourth log entry maintains readability.


859-859: Simplify switch_state property
Removed unnecessary parentheses; return expression is now more concise.

plugwise_usb/helpers/cache.py (9)

56-57: Clarify initialization error message
The multi-line raise for a missing cache folder is now clearly formatted.


64-64: Formatting: Assign cache file path
Consistent spacing around assignment improves readability.


83-83: Fix docstring formatting
Corrected the docstring to properly describe the write_cache method.


85-87: Clarify precondition check in write_cache
Raised CacheError is now formatted across multiple lines for clarity.


120-120: Improve debug log formatting
Aligned formatting of the debug call for consistency.


126-127: Clarify initialization precondition in read_cache
Enhanced readability of the error raise when cache isn't initialized.


132-134: Improve debug log for empty cache
Multi-line debug statement now follows consistent style.


156-157: Format warning on invalid cache line
Streamlined logging call across multiple lines for consistency.


159-159: Consistent assignment in read_cache loop
Assignment now properly aligned with surrounding code.

plugwise_usb/messages/requests.py (2)

314-320: Refactor _send_request signature
Method signature has been split across lines for better readability.


1268-1268: Trim trailing whitespace in docstring
Removed extra space at the end of the Response message line.

plugwise_usb/nodes/scan.py (4)

52-52: Formatting: Sensitivity medium constant
Aligned assignment with surrounding constants for consistency.


176-180: Reformat complex conditional in _motion_from_cache
Split the multi-part if condition across lines to improve clarity.


363-365: Align arguments in gather call
Each coroutine in await gather(...) is now on its own line for readability.


482-484: Reformat sensitivity_map.get call
Method parameters are now on separate lines for PEP 8 compliance.

plugwise_usb/nodes/helpers/pulses.py (3)

10-11: Approve import of MINUTE_IN_SECONDS.

Grouping and importing the new constant alongside DAY_IN_HOURS and LOGADDR_MAX is correct and keeps related time-based constants together.


172-177: Enhance debug logging with production flag.

Including self._log_production in the debug call provides full context for consumption vs. production, aiding future troubleshooting.


523-525: Maintain correct boolean XOR grouping.

The multi-line formatting around the ^ operator preserves readability and the parentheses ensure the intended XOR between the two timestamp comparisons.

plugwise_usb/nodes/node.py (2)

346-348: Preserve logical grouping in _setup_protocol.

The split condition with parentheses maintains the intended range check on required_version while improving line-length compliance.


537-539: Refactor model_info assignment for clarity.

Breaking the single-line list into multiple lines makes the conditional fallback logic more readable.

plugwise_usb/__init__.py (6)

23-25: Extract constant for uninitialized-stick error.

Defining NOT_INITIALIZED_STICK_ERROR centralizes the error message and avoids duplication in load_nodes.


175-177: Prevent changing port while connected.

Adding this guard ensures the stick’s port cannot be modified mid-connection, preventing inconsistent states.


188-191: Simplify energy reset flow with walrus operator.

The use of if result := await ... cleanly captures the outcome and reduces temporary variables.


234-238: Clarify subscription error when network uninitialized.

Raising SubscriptionError with a descriptive message aligns with expectations when _network is missing.


268-270: Improve exception message formatting in connect.

Splitting the f-string into logical parts enhances readability while preserving content.


316-318: Refine load-nodes error handling.

Raising StickError("Cannot load nodes when network is not started") clarifies the precondition for load_nodes.

.pre-commit-config.yaml (9)

7-15: Re-enable and upgrade ruff hooks with auto-fix.

Bringing back ruff@v0.11.13 and separating ruff (with --fix) from ruff-format aligns with the Core/Python-plugwise tooling approach.


20-20: Add explicit name for check-executables-have-shebangs hook.

Naming the hook improves clarity when listing and running hooks manually.


23-26: Configure no-commit-to-branch with explicit args and name.

Setting --branch=main and naming the hook enforces branch-protection locally consistent with CI.


30-31: Name pyupgrade hook explicitly.

The new "Checking pyupgrade" label makes its purpose clearer in the pre-commit report.


36-40: Refine codespell hook arguments.

Updating ignore and skip lists, along with quiet-level settings, centralizes spelling rules and matches the removed setup.cfg.


46-46: Rename bandit hook for consistency.

Using "Bandit checking" aligns the naming style across security hooks.


62-63: Configure biome-lint additional dependencies.

Specifying @biomejs/biome@1.8.3 ensures consistent formatting versions in local and CI runs.


70-71: Explicit name and stage for python-typing-update.

The "Python typing" label and [manual] stage clarify when and how the hook should be run.


77-83: Add and configure shellcheck hook.

Introducing shellcheck with --external-sources strengthens shell script linting in setup workflows.

plugwise_usb/nodes/helpers/counter.py (3)

83-88: Formatting readability improvement.
The multi-line if condition enhances readability without changing behavior.


163-168: Consistent multi-line formatting.
Restructuring the tuple unpacking and method call across multiple lines aligns with the project's style.


301-305: Maintain style consistency.
Expanding the replace(...) call over multiple lines improves clarity.

plugwise_usb/nodes/switch.py (3)

56-62: Expanded protocol features tuple.
The multi-line layout for NodeFeature constants improves maintainability and matches the style elsewhere.


93-97: Consistent region marker
Changing #endregion to # endregion aligns with the common formatting of code regions across the codebase.


105-108: Ensure trailing comma in gather call.
Adding the comma prevents syntax errors if additional calls are appended later.

plugwise_usb/nodes/circle_plus.py (3)

11-14: Reordered and formatted imports for clarity.
The multi-line grouping of request imports aligns with PEP8 and the project's import style.


18-19: Separated firmware import.
Moving the firmware support import to its own line enhances readability and keeps grouping consistent.


133-136: Docstring formatting.
Adding a blank line after the Returns: section maintains consistency in docstring structure.

scripts/complexity.sh (1)

22-26: Run complexity analysis unconditionally.
Extracting the radon command outside the conditional ensures it always runs, matching changes in other scripts.

scripts/setup.sh (3)

5-13: Env detection and venv creation
The inline logic correctly checks for an active VIRTUAL_ENV before creating one with uv or python3 -m venv. Ensure existing venv directories are preserved or handled gracefully if re-running this script.


15-17: Install uv into the venv
Installing uv via python3 -m pip is safe when venv is activated. Confirm that pip is using the venv’s environment to avoid polluting the global site-packages.


22-23: Install pre-commit hook
A direct pre-commit install is sufficient. Ensure CI workflows include this step if hooks are expected in automated checks.

scripts/run-in-env.sh (4)

1-2: Shebang and attribution
Using /usr/bin/env sh and noting the HA-core origin is fine for portability and context.


7-15: Default OSTYPE and pyenv support
The fallback for OSTYPE and the .python-version handling correctly integrate pyenv.


17-31: Virtualenv activation logic
Fallback search for common venv directories and sourcing the activate script is robust. Consider logging a warning if no venv is found and none is created upstream.


33-33: Command execution
Using exec "$@" ensures the script replaces itself with the target command. This is the correct pattern.

tests/test_usb.py (1)

785-789: Multi-line tuple formatting
The refactored features tuple in test_node_relay_and_power improves readability. The trailing comma inside a multi-line literal is correct.

.github/workflows/verify.yml (7)

7-7: Bump cache version for environment venv
Updating CACHE_VERSION to 25 invalidates stale caches as intended.


16-16: Confirm disabling of pull_request trigger
The pull_request event is commented out; ensure this is intentional so that PRs won’t run the verify workflow.


51-53: Use uv wrapper consistently for pip installs
Switching to pip install uv and uv pip install … aligns with the repository’s tooling move. Good catch.


101-101: Enable actual Ruff checks
Changing from a no-op to ruff check plugwise_usb/ tests/ correctly enforces lint rules.


106-106: Commit-formatted fixes with Ruff
Running ruff format on failures will auto-correct style issues. This matches pre-commit hooks.


203-208: Adopt uv prefix in test-cache setup
All test dependencies now install via uv pip install, consistent with setup scripts.


284-288: Clarify MyPy skip logic
The uv pip list | grep -i mypy line doesn’t gate the skip message; the script always echoes “skipping”. Verify that this is the desired behavior for issue #171.

scripts/setup_test.sh (6)

2-3: Documented origin of script
The new header clearly attributes this to HA-core and explains local adjustments.


17-19: Ensure uv is installed
Conditionally installing uv if missing guarantees the wrapper is available.


24-24: Install test requirements with uv
Single uv pip install --upgrade -e . -r ... simplifies dependency management.


33-33: Error on unknown processor
The exit-2 path ensures failure on unrecognized architectures.


38-38: Make Biome CLI executable
Granting execution rights is necessary for downstream usage.


41-43: Conditional pre-commit hook install
Installing hooks only when no args are passed avoids re-installation on CI.

scripts/tests_and_coverage.sh (9)

2-3: Copied from HA-Core with local adaptations
The header comment acknowledges provenance and intent.


12-16: Load pyenv configuration if present
Reading .python-version for pyenv compatibility is a welcome addition.


17-30: Activate existing virtualenvs robustly
The loop over venv, .venv, . under the repo root is comprehensive.


39-44: Centralize error handling in handle_command_error
Encapsulating exit status checks improves script readability.


46-49: Add biome_format helper
Automating Biome formatting with error propagation is consistent.


52-54: Install and update dependencies via uv
Pre-commit hooks and pip installs are properly sequenced.


63-67: Integrate Biome and Ruff in lint stage
Running biome_format then ruff check matches the CI workflow.


68-72: Auto-formatting on Ruff failures
Calling ruff format and handling errors ensures consistent style.


76-77: Validate lint with Pylint
The addition of pylint with error handling finalizes the lint tasks.

pyproject.toml (7)

43-43: Enable type hint publishing
Adding "plugwise_usb" = ["py.typed"] ensures PEP 561 compatibility for type checkers.


48-56: Document Core alignment markers
The comment block marking Core-aligned disables provides context.


58-72: Configure Pylint init-hook for Core plugins
Pointing to pylint/plugins from upstream Core is correct. Verify that this path exists in the project.


78-83: Extend Pylint extension-pkg-allow-list
Allow-listing av and orjson modules matches known dependencies. Confirm these packages are imported elsewhere.


86-88: Fail on Pylint info-level messages
Enforcing no I messages tightens quality gates.


95-101: Clarify disabled Pylint messages reasons
The commented rationale for disables (e.g., format vs. Ruff) aids future cleanup.


528-532: Customize import aliases for Ruff
Adding aliases for Home Assistant submodules prevents lint failures during imports.

@CoMPaTech
Copy link
Member Author

Dropped pre-commit.ci access from both usb repos

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (2)
.github/workflows/verify.yml (2)

103-113: Fix push-based auto-fix commit logic.
When pull_request is disabled, $GITHUB_HEAD_REF is empty in a push run, causing git checkout $GITHUB_HEAD_REF to fail. Use github.ref_name or derive the branch name from the event context.

Suggested diff:

-          git checkout $GITHUB_HEAD_REF
+          git checkout "${{ github.ref_name }}"

149-153: Correct failure check for pre-commit cache.
The “Fail job if cache restore failed” step references steps.cache-venv.outputs.cache-hit instead of steps.cache-precommit.outputs.cache-hit.

Apply:

- if: steps.cache-venv.outputs.cache-hit != 'true'
+ if: steps.cache-precommit.outputs.cache-hit != 'true'
🧹 Nitpick comments (3)
.pre-commit-config.yaml (2)

36-41: Remove inline “remove before merge” comment in codespell args.
The # Previous list, remove before merge comment breaks the args list. Move any legacy ignore words into a separate doc or remove this annotation.


94-97: Fix missing parenthesis in hook name.
The setup_test hook’s name: "Setup (extended for testing" is missing a closing ).

scripts/setup_test.sh (1)

1-4: Re-introduced set -e only (removed -u).
Dropping -u allows undefined variables to pass silently. Was this intentional to avoid failures on unbound vars?

Consider reinstating set -o nounset or adding explicit checks for required variables.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 403b2c5 and 95a2c30.

📒 Files selected for processing (34)
  • .github/workflows/verify.yml (7 hunks)
  • .pre-commit-config.yaml (2 hunks)
  • plugwise_usb/__init__.py (7 hunks)
  • plugwise_usb/api.py (1 hunks)
  • plugwise_usb/connection/__init__.py (1 hunks)
  • plugwise_usb/connection/queue.py (3 hunks)
  • plugwise_usb/connection/receiver.py (1 hunks)
  • plugwise_usb/connection/sender.py (4 hunks)
  • plugwise_usb/constants.py (1 hunks)
  • plugwise_usb/helpers/cache.py (4 hunks)
  • plugwise_usb/helpers/util.py (2 hunks)
  • plugwise_usb/messages/__init__.py (1 hunks)
  • plugwise_usb/messages/properties.py (1 hunks)
  • plugwise_usb/messages/requests.py (2 hunks)
  • plugwise_usb/messages/responses.py (2 hunks)
  • plugwise_usb/network/__init__.py (2 hunks)
  • plugwise_usb/network/cache.py (1 hunks)
  • plugwise_usb/nodes/celsius.py (1 hunks)
  • plugwise_usb/nodes/circle.py (2 hunks)
  • plugwise_usb/nodes/circle_plus.py (1 hunks)
  • plugwise_usb/nodes/helpers/__init__.py (1 hunks)
  • plugwise_usb/nodes/helpers/counter.py (3 hunks)
  • plugwise_usb/nodes/helpers/pulses.py (3 hunks)
  • plugwise_usb/nodes/helpers/subscription.py (2 hunks)
  • plugwise_usb/nodes/node.py (5 hunks)
  • plugwise_usb/nodes/scan.py (5 hunks)
  • plugwise_usb/nodes/sed.py (1 hunks)
  • plugwise_usb/nodes/sense.py (2 hunks)
  • plugwise_usb/nodes/stealth.py (1 hunks)
  • plugwise_usb/nodes/switch.py (3 hunks)
  • scripts/pre-commit.sh (0 hunks)
  • scripts/setup_test.sh (1 hunks)
  • tests/stick_test_data.py (1 hunks)
  • tests/test_usb.py (3 hunks)
💤 Files with no reviewable changes (1)
  • scripts/pre-commit.sh
✅ Files skipped from review due to trivial changes (10)
  • plugwise_usb/connection/receiver.py
  • plugwise_usb/constants.py
  • plugwise_usb/nodes/circle_plus.py
  • plugwise_usb/nodes/stealth.py
  • plugwise_usb/connection/init.py
  • plugwise_usb/nodes/helpers/init.py
  • plugwise_usb/nodes/helpers/subscription.py
  • plugwise_usb/messages/requests.py
  • plugwise_usb/init.py
  • plugwise_usb/messages/properties.py
🚧 Files skipped from review as they are similar to previous changes (20)
  • plugwise_usb/nodes/celsius.py
  • plugwise_usb/messages/init.py
  • plugwise_usb/network/cache.py
  • plugwise_usb/nodes/sense.py
  • plugwise_usb/nodes/helpers/counter.py
  • plugwise_usb/connection/queue.py
  • plugwise_usb/api.py
  • plugwise_usb/connection/sender.py
  • tests/stick_test_data.py
  • plugwise_usb/nodes/sed.py
  • plugwise_usb/helpers/cache.py
  • plugwise_usb/helpers/util.py
  • plugwise_usb/network/init.py
  • plugwise_usb/nodes/helpers/pulses.py
  • plugwise_usb/nodes/node.py
  • plugwise_usb/nodes/switch.py
  • plugwise_usb/messages/responses.py
  • plugwise_usb/nodes/scan.py
  • plugwise_usb/nodes/circle.py
  • tests/test_usb.py
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/verify.yml

104-104: shellcheck reported issue in this script: SC2086:info:5:91: Double quote to prevent globbing and word splitting

(shellcheck)


104-104: shellcheck reported issue in this script: SC2086:info:6:14: Double quote to prevent globbing and word splitting

(shellcheck)


104-104: shellcheck reported issue in this script: SC2086:info:8:17: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (15)
.pre-commit-config.yaml (13)

7-14: Re-enabled and split Ruff hooks look solid.
Reinstating the ruff hook with --fix and a separate ruff-format hook is aligned with Core/Python-plugwise standards.


20-23: Explicit naming for built-in pre-commit hooks is clear.
check-executables-have-shebangs and no-commit-to-branch now have descriptive name fields.


30-31: PyUpgrade hook naming update is good.
Having a consistent hook name enhances readability in hook logs.


46-52: Bandit configuration is correctly scoped.
Specifying --configfile and limiting files to plugwise_usb and tests directories is good practice.


56-57: YAML lint hook name clarified.
Adding "YAML linting" improves hook UI.


62-63: Biome lint hook additional dependency pinned.
Locking @biomejs/biome@1.8.3 ensures deterministic formatting.


70-76: Manual Python typing hook setup is fine.
Leaving python-typing-update as a manual hook fits an infrequent migration workflow.


78-83: ShellCheck hook with --external-sources is appropriate.
This will catch issues in sourced scripts.


90-94: Local setup hook logic is clear.
Using a wrapper to ensure venv exists before other hooks run is aligned with the new scripting approach.


105-110: PyLint hook configuration is well-defined.
Invoking pylint -j 0 for all Python files under plugwise_usb/ is appropriate.


112-117: Testing hook with NO_FIXTURES="1" is intentional and documented.
Running tests without fixtures in CI aligns with upstream conventions.


117-121: Biome local hook ready for unknown file types.
Good to have --files-ignore-unknown=true.


125-126: MarkdownLint hook naming updated.
Clear hook names improve readability.

.github/workflows/verify.yml (2)

15-17: Verify removal of pull_request trigger.
Disabling the pull_request event stops CI from running on GitHub PRs. Confirm this aligns with your intent to only run on push, workflow_dispatch, and a schedule.


51-54: Ensure uv tool is available on runner.
You install uv after creating the venv, but subsequent uv pip install calls assume it’s on PATH. Confirm no intermittent path issues.

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.12%. Comparing base (9247974) to head (afa96a6).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #263   +/-   ##
=======================================
  Coverage   81.12%   81.12%           
=======================================
  Files          36       36           
  Lines        7502     7502           
=======================================
  Hits         6086     6086           
  Misses       1416     1416           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CoMPaTech CoMPaTech marked this pull request as ready for review June 18, 2025 11:55
@CoMPaTech CoMPaTech requested a review from a team as a code owner June 18, 2025 11:55
@CoMPaTech
Copy link
Member Author

@CodeRabbit summary

Copy link
Contributor

@bouwew bouwew left a comment

Choose a reason for hiding this comment

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

Thanks @CoMPaTech !

@coderabbitai
Copy link

coderabbitai bot commented Jun 18, 2025

✅ Actions performed

Summary regeneration triggered.

@CoMPaTech CoMPaTech merged commit ed7cc81 into main Jun 18, 2025
27 of 28 checks passed
@CoMPaTech CoMPaTech deleted the ruff branch June 18, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request pre-commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants