Skip to content

Fix: PEP8 spacing in logic factory + tests for string time_resolution_minutes#306

Merged
MaStr merged 2 commits intofix-type-errorsfrom
copilot/sub-pr-305
Mar 17, 2026
Merged

Fix: PEP8 spacing in logic factory + tests for string time_resolution_minutes#306
MaStr merged 2 commits intofix-type-errorsfrom
copilot/sub-pr-305

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

Addresses review comments from PR #305. The logic factory had a PEP8 violation in its signature, and there were no tests covering the string→int coercion of time_resolution_minutes (e.g. when provided by Home Assistant).

Changes

src/batcontrol/logic/logic.py

  • Fixed missing space after comma in create_logic signature: int,configint, config

tests/batcontrol/test_core.py

  • Added TestTimeResolutionString with parametrized coverage for '60' and '15' string inputs:
    • test_string_time_resolution_initialises_without_error — asserts Batcontrol.__init__ accepts string resolution and stores it as int
    • test_logic_factory_accepts_string_resolution_as_int — asserts LogicFactory.create_logic produces a DefaultLogic with the correct interval_minutes
# Previously would raise TypeError if HA provided time_resolution_minutes as a string
bc = Batcontrol({..., 'time_resolution_minutes': '60'})
assert isinstance(bc.time_resolution, int)  # passes — coercion happens in __init__
assert bc.time_resolution == 60

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
Copilot AI changed the title [WIP] [302] Fix type error for interval_minutes Fix: PEP8 spacing in logic factory + tests for string time_resolution_minutes Mar 17, 2026
Copilot AI requested a review from MaStr March 17, 2026 15:12
@MaStr MaStr marked this pull request as ready for review March 17, 2026 15:12
@MaStr MaStr merged commit 4d1323e into fix-type-errors Mar 17, 2026
@MaStr MaStr deleted the copilot/sub-pr-305 branch March 17, 2026 15:13
MaStr added a commit that referenced this pull request Mar 17, 2026
* Transport time resolution as a proper parameter

* Fix: PEP8 spacing in logic factory + tests for string time_resolution_minutes (#306)

* Initial plan

* Fix PEP8 spacing in logic.py and add string time_resolution tests

Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MaStr <1036501+MaStr@users.noreply.github.com>
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.

2 participants