Skip to content

Centralize version parsing and normalization#575

Merged
firstof9 merged 4 commits into
mainfrom
centralize-version-parsing
May 21, 2026
Merged

Centralize version parsing and normalization#575
firstof9 merged 4 commits into
mainfrom
centralize-version-parsing

Conversation

@firstof9
Copy link
Copy Markdown
Owner

@firstof9 firstof9 commented May 21, 2026

This PR centralizes the duplicate version parsing and normalization logic into a single helper module.

Changes

  • openevsehttp/utils.py:
    • Created a new module containing normalize_version and get_awesome_version.
  • openevsehttp/properties.py:
    • Refactored wifi_firmware to use normalize_version.
  • openevsehttp/client.py:
    • Refactored _version_check to use get_awesome_version.
  • openevsehttp/commands.py:
    • Refactored firmware_check to use get_awesome_version.

This reduces code duplication and ensures consistent parsing across the library.

Summary by CodeRabbit

  • Refactor
    • Consolidated firmware version parsing logic across multiple components into centralized utility functions to ensure more reliable and consistent version detection throughout the application
    • Enhanced handling of non-standard firmware version formats (including development and special releases) to improve system stability and operational compatibility
    • Reduced code duplication and improved overall maintainability of version processing

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 65c6b27f-df21-47a5-8f24-b527ffc0f2fb

📥 Commits

Reviewing files that changed from the base of the PR and between 2c98ff5 and 6143fb0.

📒 Files selected for processing (4)
  • openevsehttp/client.py
  • openevsehttp/commands.py
  • openevsehttp/properties.py
  • openevsehttp/utils.py

📝 Walkthrough

Walkthrough

Firmware version parsing logic—previously duplicated across client checking, command detection, and property formatting—is consolidated into two shared utility functions in a new utils.py module. All existing call sites updated to use these utilities, eliminating redundant local regex and string-handling code.

Changes

Version Parsing Consolidation

Layer / File(s) Summary
Shared version utilities
openevsehttp/utils.py
New normalize_version() removes "dev" markers and truncates to three dot-separated components; get_awesome_version() normalizes input, maps "master" to "dev", extracts X.Y.Z via regex, and returns AwesomeVersion instance.
Client version checking
openevsehttp/client.py
_version_check() now uses get_awesome_version() to derive firmware version and rejects non-standard versions when strategy is "unknown". The re import removed and utility imported.
Command firmware detection
openevsehttp/commands.py
firmware_check() replaces manual version normalization with get_awesome_version() call, simplifying logic and updating debug logs.
Property version formatting
openevsehttp/properties.py
wifi_firmware property calls normalize_version() to format version strings instead of local "dev"-stripping logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Version parsing scattered wide,
Now in utils.py unified!
Three callers hop along the path,
Sharing logic—no more math.
Cleaner code, the fuzzy way! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Centralize version parsing and normalization' directly and accurately summarizes the main change: moving duplicate version parsing/normalization logic into a shared utility module used across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch centralize-version-parsing

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.

@firstof9
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@firstof9 firstof9 merged commit 520c0e8 into main May 21, 2026
11 checks passed
@firstof9 firstof9 deleted the centralize-version-parsing branch May 21, 2026 02:08
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.

1 participant