Move UNITS registry out of tmt.hardware - #5192
Open
HarshRajSinghania wants to merge 2 commits into
Open
HarshRajSinghania wants to merge 2 commits into
HarshRajSinghania wants to merge 2 commits into
Conversation
added 2 commits
September 23, 2026 15:07
Relocate the shared Pint UnitRegistry to tmt.utils.units so non-hardware code does not need to import tmt.hardware. Keep tmt.hardware.UNITS as a compatibility re-export. Fixes teemtee#5171
This branch has not been deployed
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.
Summary
Move the shared Pint
UnitRegistry(UNITS) fromtmt.hardware.constraintsto a dedicatedtmt.utils.unitsmodule so non-hardware code can convert quantities without importingtmt.hardware.Motivation
Fixes #5171. The registry started in hardware constraints because it was only used for memory/disk sizes. It is now also used for log size limits, directory sizes, and similar values that are not hardware requirements.
Implementation
tmt/utils/units.pywithUNITS(and theSizetype alias underTYPE_CHECKING).UNITSfrom there intmt.hardware.constraints.tmt.hardware.UNITSas a re-export so existing hardware/provision call sites keep working.tmt.utils.units:tmt.utils.normalize_data_amounttmt.base.coretmt.steps.report.reportportaltests/unit/test_data_size_validation.pyProvision plugins (
testcloud,bootc) still usetmt.hardware.UNITS; that remains valid because they already depend on hardware helpers.Testing
Could not run the full tmt suite in this environment (project extras such as
fmfare not installed here). Changes are import-path only;tmt.hardware.UNITSis the same registry object.Suggested checks: