neuralqx.utils.module.version_check module¶
Backward-compatible compatibility layer for version utilities.
The main implementation now lives in neuralqx.utils.module.version.
- exception InvalidVersion¶
Bases:
ValueErrorRaised when a version string is not a valid version.
>>> Version("invalid") Traceback (most recent call last): ... packaging.version.InvalidVersion: Invalid version: 'invalid'
- class Version(value='0')¶
Bases:
objectStrict semantic version object used by neuraLQX.
This class is the canonical, strongly-typed representation of versions inside
neuralqx.utils.module.version. It wrapspackaging.version.Versionand enforces full PEP 440 validation at construction time.This class does not perform lexical fallbacks, every comparison is semantic and every input must be parseable as a valid version.
- Accepted constructor inputs
Versionaccepts version-like values viaVersionInput, including:Versioninstancesstring versions (for example
"1.2.3","1.2.3rc1","1.2.3.post1")integer versions (for example
1->"1")component sequences (for example
(1, 2, 3)->"1.2.3")packaging.version.Versioninstances
- Comparison semantics
- Ordering follows PEP 440 exactly. For the same base release
X.Y.Z: dev<a(alpha) <b(beta) <rc< final <post.
- Ordering follows PEP 440 exactly. For the same base release
Examples
Version("1.1.0.dev1") < Version("1.1.0.dev2") < Version("1.1.0")Version("1.1.0") < Version("1.1.0.post1")Version("1.1.0rc1") < Version("1.1.0")
- Error behavior
Invalid version values raise
packaging.version.InvalidVersion.- Unsupported operand types in comparisons return
NotImplementedso Python can attempt reflected operations.
- Unsupported operand types in comparisons return
- Invalid but coercible comparison values (for example
"parrot") raise
- Invalid but coercible comparison values (for example
- Exposed properties
source: normalized textual source used to build the object.canonical: canonical PEP 440 form.release: release tuple from the parsed version.major,minor,patch: convenience release components.
- Notes
Use
NeuralqxVersionwhen you explicitly need string-subclass behavior.Use
Versionfor strict policy checks, ordering, and dependency gating.
- class NeuralqxVersion(value: object = '0')¶
Bases:
strA version string that behaves like
strwhile comparing semantically.This class accepts comparison against: -
Version-NeuralqxVersion- version strings - integer tuples/lists such as(1, 2, 3)
- coerce_version_text(value)¶
Normalise a version-like object into a textual representation.
- Return type:
- coerce_version(value)¶
Alias for
parse_version().- Return type:
- try_parse_version(value)¶
Attempt to parse, returning
Nonewhen parsing fails.
- normalize_version(value, *, width=3, strict=True)¶
Convert a version-like value into a release tuple.
If
strict=False, invalid values are normalised to zeros.
- get_module_version(module, *, strict=True)¶
Return the module version as
Version.Missing
__version__is treated as0.0.0. Ifstrict=False, invalid versions returnNone.
- get_module_neuralqx_version(module, *, strict=True)¶
Return the module version as
NeuralqxVersion.Missing
__version__is treated as0.0.0. Ifstrict=False, invalid versions returnNone.- Return type: