fix: adapt FirmwareID to work with origin#3
Merged
MrKevinWeiss merged 1 commit intomasterfrom May 5, 2025
Merged
Conversation
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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." | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Things change and so must we...