Skip to content

Commit

Permalink
Use classmethod instead of staticmethod for _VersionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Jul 10, 2024
1 parent 83ca71b commit f8466d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hdf5plugin/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)((?P<prerelease>a|b|rc)(?P<serial>\d+))?"
match = re.fullmatch(pattern, version, re.ASCII)
fields = {k: v for k, v in match.groupdict().items() if v is not None}
Expand All @@ -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)

0 comments on commit f8466d9

Please sign in to comment.