Skip to content

fix: adapt FirmwareID to work with origin#3

Merged
MrKevinWeiss merged 1 commit intomasterfrom
pr/originfw
May 5, 2025
Merged

fix: adapt FirmwareID to work with origin#3
MrKevinWeiss merged 1 commit intomasterfrom
pr/originfw

Conversation

@MrKevinWeiss
Copy link
Collaborator

Things change and so must we...

@MrKevinWeiss MrKevinWeiss requested a review from Copilot May 5, 2025 08:14
Copy link

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 adapts the FirmwareID parsing logic to correctly handle firmware identifiers containing the keyword "origin" in the version string. Key changes include:

  • Adding a new test case in tests/test_firmware_id.py to ensure origin-based identifiers are parsed correctly.
  • Introducing a new regex (_IDENTIFIER_RE_ORIGIN) in FirmwareID to handle the origin format.
  • Modifying post_init to fall back to the origin regex when the default pattern does not match.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_firmware_id.py Adds a test for origin-based firmware identifiers.
src/lob_hlpr/lib_types.py Updates FirmwareID regex matching to support "origin" formats.

try:
m = self._IDENTIFIER_RE.match(self.id_string)
if not m:
m = self._IDENTIFIER_RE_ORIGIN.match(self.id_string)
Copy link

Copilot AI May 5, 2025

Choose a reason for hiding this comment

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

Consider adding an explicit error check for when both regex matches return None, so that a clear ValueError is raised rather than relying on a later exception. For example, after attempting both matches, check if m is None and then raise ValueError with an informative message.

Suggested change
m = self._IDENTIFIER_RE_ORIGIN.match(self.id_string)
m = self._IDENTIFIER_RE_ORIGIN.match(self.id_string)
if not m:
raise ValueError(
f"Invalid firmware identifier string: '{self.id_string}'. "
"It does not match the expected formats."
)

Copilot uses AI. Check for mistakes.
@MrKevinWeiss MrKevinWeiss merged commit d338ac1 into master May 5, 2025
5 checks passed
@MrKevinWeiss MrKevinWeiss deleted the pr/originfw branch May 5, 2025 08:16
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