Skip to content

Remove boilerplate needed for hardware requirement parsers#4859

Draft
happz wants to merge 4 commits into
mainfrom
bardware-parsers-simplified
Draft

Remove boilerplate needed for hardware requirement parsers#4859
happz wants to merge 4 commits into
mainfrom
bardware-parsers-simplified

Conversation

@happz
Copy link
Copy Markdown
Contributor

@happz happz commented May 6, 2026

With a combination of pairing requirement names and constraint classes and custom functions for more complex cases, the amount of code needed to add new requirements is much smaller now.

Pull Request Checklist

  • implement the feature

@happz happz added this to planning May 6, 2026
@happz happz added area | hardware Implementation of hardware requirements code | style Code style changes not affecting functionality code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. labels May 6, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning May 6, 2026
@happz happz added the ci | full test Pull request is ready for the full test execution label May 6, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the hardware requirement parsing logic by introducing a more structured approach with dedicated parser classes and a registry. It replaces several manual parsing functions with a unified system of single-level, double-level, and indexed parsers, while also updating type hints to use Self. A recommendation was made to use a more specific SpecificationError instead of a generic Exception when encountering unhandled requirements.


if 'hostname' in spec:
group.constraints += [_parse_hostname(spec)]
raise Exception(f"Unhandled requirement '{requirement}'.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use a more specific exception like SpecificationError instead of the generic Exception when a hardware requirement cannot be handled. This aligns with the error handling patterns used elsewhere in the tmt codebase for metadata issues.

Suggested change
raise Exception(f"Unhandled requirement '{requirement}'.")
raise tmt.utils.SpecificationError(f"Unhandled requirement '{requirement}'.")
References
  1. Use specific exceptions like SpecificationError for metadata issues to align with codebase patterns. (link)

@happz happz force-pushed the bardware-parsers-simplified branch from 0874185 to 310038e Compare May 11, 2026 13:43
happz added 3 commits May 13, 2026 12:58
With a combination of pairing requirement names and constraint classes
and custom functions for more complex cases, the amount of code needed
to add new requirements is much smaller now.
@happz happz force-pushed the bardware-parsers-simplified branch from 310038e to 78fee3c Compare May 13, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | hardware Implementation of hardware requirements ci | full test Pull request is ready for the full test execution code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. code | style Code style changes not affecting functionality

Projects

Status: backlog

Development

Successfully merging this pull request may close these issues.

1 participant