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: ValueError

Raised when a version string is not a valid version.

>>> Version("invalid")
Traceback (most recent call last):
    ...
packaging.version.InvalidVersion: Invalid version: 'invalid'
VersionInput

alias of object

class Version(value='0')

Bases: object

Strict semantic version object used by neuraLQX.

This class is the canonical, strongly-typed representation of versions inside neuralqx.utils.module.version. It wraps packaging.version.Version and 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
Version accepts version-like values via VersionInput, including:
  • Version instances

  • string 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.Version instances

Comparison semantics
Ordering follows PEP 440 exactly. For the same base release X.Y.Z:

dev < a (alpha) < b (beta) < rc < final < post.

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
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 NeuralqxVersion when you explicitly need string-subclass behavior.

  • Use Version for strict policy checks, ordering, and dependency gating.

class NeuralqxVersion(value: object = '0')

Bases: str

A version string that behaves like str while 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:

str

coerce_version(value)

Alias for parse_version().

Return type:

Version

parse_version(value)

Parse a strict semantic version.

Return type:

Version

try_parse_version(value)

Attempt to parse, returning None when parsing fails.

Return type:

Version | None

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.

Return type:

tuple[int, ...]

get_module_version(module, *, strict=True)

Return the module version as Version.

Missing __version__ is treated as 0.0.0. If strict=False, invalid versions return None.

Return type:

Version | None

get_module_neuralqx_version(module, *, strict=True)

Return the module version as NeuralqxVersion.

Missing __version__ is treated as 0.0.0. If strict=False, invalid versions return None.

Return type:

NeuralqxVersion | None

get_module_version_string(module)

Return the module’s raw __version__ string or "unknown".

Return type:

str