diff --git a/src/hdf5plugin/_version.py b/src/hdf5plugin/_version.py index ba54e388..e3faa357 100644 --- a/src/hdf5plugin/_version.py +++ b/src/hdf5plugin/_version.py @@ -38,8 +38,8 @@ class _VersionInfo(NamedTuple): releaselevel: str = "final" serial: int = 0 - @staticmethod - def from_string(version: str) -> "_VersionInfo": + @classmethod + def from_string(cls, version: str) -> "_VersionInfo": pattern = r"(?P\d+)\.(?P\d+)\.(?P\d+)((?Pa|b|rc)(?P\d+))?" match = re.fullmatch(pattern, version, re.ASCII) fields = {k: v for k, v in match.groupdict().items() if v is not None} @@ -50,7 +50,7 @@ def from_string(version: str) -> "_VersionInfo": ] version_fields = {k: int(v) for k, v in fields.items()} - return _VersionInfo(releaselevel=releaselevel, **version_fields) + return cls(releaselevel=releaselevel, **version_fields) version_info = _VersionInfo.from_string(version)