Skip to content

[WIP][RFC] feat(types): harden product version with validated ProductVersion type#433

Draft
okurz wants to merge 1 commit intoopenSUSE:masterfrom
okurz:feature/035_get_product_version_strict_type
Draft

[WIP][RFC] feat(types): harden product version with validated ProductVersion type#433
okurz wants to merge 1 commit intoopenSUSE:masterfrom
okurz:feature/035_get_product_version_strict_type

Conversation

@okurz
Copy link
Copy Markdown
Member

@okurz okurz commented Mar 11, 2026

Motivation:
Product version extraction used plain strings and empty strings for missing
values, causing ambiguity and potential errors. PR #429 feedback requested
stricter definitions and better type safety in
#429 (review)

Design Choices:

  • Introduced ProductVersion string subclass in types.py with regex-based
    validation in new.
  • Refactored gitea.py to return ProductVersion | None instead of "".
  • Moved VERSION_EXTRACT_REGEX to types.py to centralize logic.
  • Updated extraction logic to use fullmatch for stricter validation.
  • Updated dependent code to use explicit is not None checks.

User Benefits:

  • Improved type safety and runtime validation of product versions.
  • Clearer API contracts with Optional types.
  • Centralized version parsing logic improves maintainability.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f2d9742) to head (34ab418).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #433   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           97        97           
  Lines         9690      9709   +19     
  Branches       514       515    +1     
=========================================
+ Hits          9690      9709   +19     

☔ 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.

@okurz okurz changed the title feat(types): harden product version with validated ProductVersion type [WIP][RFC] feat(types): harden product version with validated ProductVersion type Mar 11, 2026
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch 3 times, most recently from 660e056 to 1b62f94 Compare March 17, 2026 10:32
@asmorodskyi asmorodskyi self-requested a review March 18, 2026 08:28
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch 10 times, most recently from 17e9e66 to a660001 Compare March 24, 2026 11:25
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch 5 times, most recently from f9e5833 to c64514b Compare March 27, 2026 11:10
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch 2 times, most recently from 0d8c127 to 8b83552 Compare April 1, 2026 15:30
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch 6 times, most recently from c577cba to 01e475f Compare April 16, 2026 19:48
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch from 01e475f to 96b1a0d Compare April 16, 2026 20:03
Motivation:
Product version extraction used plain strings and empty strings for missing
values, causing ambiguity and potential errors. PR openSUSE#429 feedback requested
stricter definitions and better type safety.

Design Choices:
- Introduced ProductVersion string subclass in types.py with regex-based
  validation in __new__.
- Refactored gitea.py to return ProductVersion | None instead of "".
- Moved VERSION_EXTRACT_REGEX to types.py to centralize logic.
- Updated extraction logic to use fullmatch for stricter validation.
- Updated dependent code to use explicit is not None checks.

User Benefits:
- Improved type safety and runtime validation of product versions.
- Clearer API contracts with Optional types.
- Centralized version parsing logic improves maintainability.
@okurz okurz force-pushed the feature/035_get_product_version_strict_type branch from 96b1a0d to 34ab418 Compare April 20, 2026 08:50
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