Remove boilerplate needed for hardware requirement parsers#4859
Conversation
There was a problem hiding this comment.
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}'.") |
There was a problem hiding this comment.
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.
| raise Exception(f"Unhandled requirement '{requirement}'.") | |
| raise tmt.utils.SpecificationError(f"Unhandled requirement '{requirement}'.") |
References
- Use specific exceptions like SpecificationError for metadata issues to align with codebase patterns. (link)
0874185 to
310038e
Compare
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.
310038e to
78fee3c
Compare
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