-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lxmlh/version.py: changed reading VERSION
- Loading branch information
Showing
1 changed file
with
4 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
"""Version information for lxmlh package.""" | ||
import importlib.metadata | ||
from typing import Union | ||
from typing import Tuple, Union | ||
|
||
|
||
def _get_version_tuple() -> tuple: | ||
def _get_version_tuple() -> Tuple[Union[int, str]]: | ||
def as_integer(string: str) -> Union[int, str]: | ||
try: | ||
return int(string) | ||
except ValueError: # pragma: no cover | ||
return string # pragma: no cover | ||
|
||
return tuple( | ||
as_integer(v) for v in importlib.metadata.version("lxmlh").strip().split(".") | ||
) | ||
with open("VERSION", encoding="UTF-8") as versionFile: | ||
return tuple(as_integer(v) for v in versionFile.read().strip()) | ||
|
||
|
||
__version__ = _get_version_tuple() |