diff --git a/RUN_complexity.launch b/RUN_complexity.launch
index f29538b..5422619 100644
--- a/RUN_complexity.launch
+++ b/RUN_complexity.launch
@@ -7,7 +7,7 @@
-
+
diff --git a/RUN_mkdocs.launch b/RUN_mkdocs.launch
index bb142ed..31fdb36 100644
--- a/RUN_mkdocs.launch
+++ b/RUN_mkdocs.launch
@@ -10,7 +10,7 @@
-
+
diff --git a/RUN_quality.launch b/RUN_quality.launch
index 43ae6da..7c59c30 100644
--- a/RUN_quality.launch
+++ b/RUN_quality.launch
@@ -7,7 +7,7 @@
-
+
diff --git a/RUN_unittest.launch b/RUN_unittest.launch
index 78228a9..af0da74 100644
--- a/RUN_unittest.launch
+++ b/RUN_unittest.launch
@@ -7,7 +7,7 @@
-
+
diff --git a/helpers/types_check.py b/helpers/types_check.py
index 26b7942..e909464 100644
--- a/helpers/types_check.py
+++ b/helpers/types_check.py
@@ -31,6 +31,7 @@ class types_check(helper_withresults_base):
"--explicit-package-bases",
# "--strict-equality",
# "--check-untyped-defs",
+ "--enable-incomplete-feature=Unpack",
# reports generation
"--cobertura-xml-report",
str(cls.get_result_dir()),
diff --git a/src/pygitversionhelper/data/__init__.py b/src/pygitversionhelper/data/__init__.py
new file mode 100644
index 0000000..5858865
--- /dev/null
+++ b/src/pygitversionhelper/data/__init__.py
@@ -0,0 +1,7 @@
+# pygitversionhelper (c) by chacha
+#
+# pygitversionhelper is licensed under a
+# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported License.
+#
+# You should have received a copy of the license along with this
+# work. If not, see .
diff --git a/src/pygitversionhelper/gitversionhelper.py b/src/pygitversionhelper/gitversionhelper.py
index 910ba73..904f842 100644
--- a/src/pygitversionhelper/gitversionhelper.py
+++ b/src/pygitversionhelper/gitversionhelper.py
@@ -5,6 +5,7 @@
#
# You should have received a copy of the license along with this
# work. If not, see .
+
"""
This project try to help doing handy operations with git when
dealing with project versioning and tags on python project -
@@ -28,16 +29,38 @@ Note: _Other Parameters_ are **kwargs
from __future__ import annotations
+from typing import TYPE_CHECKING, cast, TypedDict, Literal
import os
import subprocess
import re
from copy import copy
import logging
+from pathlib import Path
from packaging.version import VERSION_PATTERN as packaging_VERSION_PATTERN
+from typing_extensions import reveal_type
+
+if TYPE_CHECKING:
+ from typing import List, Optional, Any, Dict
+ from typing_extensions import Unpack
+
+ TKwargs = TypedDict(
+ "TKwargs",
+ {
+ "version_std": Optional[str],
+ "same_branch": Optional[bool],
+ "formated_output": Optional[bool],
+ "bump_type": Optional[str],
+ "bump_dev_strategy": Optional[str],
+ "merged_output": Optional[bool],
+ "ignore_unknown_tags": Optional[bool],
+ "output_format": Optional[str],
+ },
+ total=False,
+ )
-def _exec(cmd: str, root: str | os.PathLike | None = None, raw: bool = False) -> list[str]:
+def _exec(cmd: str, root: Optional[str | os.PathLike[str]] = None, raw: bool = False) -> str | List[str]:
"""
helper function to handle system cmd execution
Args:
@@ -47,10 +70,18 @@ def _exec(cmd: str, root: str | os.PathLike | None = None, raw: bool = False) ->
a list of command's return lines
"""
+ _root: Path
+ if isinstance(root, str):
+ _root = Path(root)
+ elif isinstance(root, os.PathLike):
+ _root = Path(root)
+ else:
+ _root = Path(os.getcwd())
+
p = subprocess.run(
cmd,
text=True,
- cwd=root,
+ cwd=_root,
capture_output=True,
check=False,
timeout=2,
@@ -63,7 +94,7 @@ def _exec(cmd: str, root: str | os.PathLike | None = None, raw: bool = False) ->
if int(p.returncode) < 0:
raise gitversionhelper.unknownGITError(p.stderr)
- if raw:
+ if raw is True:
return p.stdout
lines = p.stdout.splitlines()
return [line.rstrip() for line in lines if line.rstrip()]
@@ -129,8 +160,6 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
class containing methods focusing on commits
"""
- __OptDict = {"same_branch": "same_branch", "merged_output": "merged_output"}
-
class commitException(gitversionhelperException):
"""
generic commit exception
@@ -142,7 +171,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
"""
@classmethod
- def getMessagesSinceTag(cls, tag: str, **kwargs) -> str:
+ def getMessagesSinceTag(cls, tag: str, **kwargs: Unpack[TKwargs]) -> str | List[str]:
"""
retrieve a commits message history from repository
from Latest commit to the given tag
@@ -155,7 +184,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
current_commit_id = cls.getLast(**kwargs)
tag_commit_id = cls.getFromTag(tag)
- if (cls.__OptDict["same_branch"] in kwargs) and (kwargs[cls.__OptDict["same_branch"]] is True):
+ if ("same_branch" in kwargs) and (kwargs["same_branch"] is True):
commits = _exec(f"git rev-list --first-parent --ancestry-path {tag_commit_id}..{current_commit_id}")
else:
commits = _exec(f"git rev-list --ancestry-path {tag_commit_id}..{current_commit_id}")
@@ -163,8 +192,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
for commit in commits:
result.append(cls.getMessage(commit))
- if (cls.__OptDict["merged_output"] in kwargs) and (kwargs[cls.__OptDict["merged_output"]] is True):
- print("JOIN")
+ if ("merged_output" in kwargs) and (kwargs["merged_output"] is True):
return os.linesep.join(result)
return result
@@ -182,7 +210,8 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
f'git log -z --pretty="tformat:%B%-C()" -n 1 {commit_hash}',
None,
True,
- ).rstrip("\x00")
+ )
+ res = cast(str, res).rstrip("\x00")
except gitversionhelper.unknownGITFatalError as _e:
raise cls.commitNotFound("no commit found in commit history") from _e
@@ -206,7 +235,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return res[0]
@classmethod
- def getLast(cls, **kwargs) -> str:
+ def getLast(cls, **kwargs: Unpack[TKwargs]) -> str:
"""
retrieve last commit from repository
Keyword Arguments:
@@ -214,7 +243,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
the commit Id
"""
- if (cls.__OptDict["same_branch"] in kwargs) and (kwargs[cls.__OptDict["same_branch"]] is True):
+ if ("same_branch" in kwargs) and (kwargs["same_branch"] is True):
try:
res = _exec("git rev-parse HEAD")
except gitversionhelper.unknownGITFatalError as _e:
@@ -231,7 +260,6 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
class containing methods focusing on tags
"""
- __OptDict = {"same_branch": "same_branch"}
__validGitTagSort = [
"",
"v:refname",
@@ -258,25 +286,25 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
"""
@classmethod
- def getTags(cls, sort: str = "taggerdate", **kwargs) -> list[str | None]:
+ def getTags(cls, Sort: str = "taggerdate", **kwargs: Unpack[TKwargs]) -> List[str]:
"""
retrieve all tags from a repository
Args:
- sort: sorting constraints (git format)
+ Sort: sorting constraints (git format)
Returns:
the tags list
"""
- if sort not in cls.__validGitTagSort:
- raise gitversionhelper.wrongArguments("sort option not in allowed list")
+ if Sort not in cls.__validGitTagSort:
+ raise gitversionhelper.wrongArguments("Sort option not in allowed list")
- if (cls.__OptDict["same_branch"] in kwargs) and (kwargs[cls.__OptDict["same_branch"]] is True):
+ if ("same_branch" in kwargs) and (kwargs["same_branch"] is True):
currentBranch = _exec("git rev-parse --abbrev-ref HEAD")
- return list(reversed(_exec(f"git tag --merged {currentBranch[0]} --sort={sort}")))
- return list(reversed(_exec(f"git tag -l --sort={sort}")))
+ return list(reversed(_exec(f"git tag --merged {currentBranch[0]} --sort={Sort}")))
+ return list(reversed(_exec(f"git tag -l --sort={Sort}")))
@classmethod
- def getLastTag(cls, **kwargs) -> str | None:
+ def getLastTag(cls, **kwargs: Unpack[TKwargs]) -> str | None:
"""
retrieve the Latest tag from a repository
Keyword Arguments:
@@ -284,7 +312,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
the tag
"""
- if (cls.__OptDict["same_branch"] in kwargs) and (kwargs[cls.__OptDict["same_branch"]] is True):
+ if ("same_branch" in kwargs) and (kwargs["same_branch"] is True):
res = _exec("git describe --tags --first-parent --abbrev=0")
else:
res = _exec("git rev-list --tags --date-order --max-count=1")
@@ -298,7 +326,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return res[0]
@classmethod
- def getDistanceFromTag(cls, tag: str = None, **kwargs) -> int:
+ def getDistanceFromTag(cls, tag: Optional[str] = None, **kwargs: Unpack[TKwargs]) -> int:
"""
retrieve the distance between Latest commit and tag in the repository
Arguments:
@@ -317,14 +345,11 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
class containing methods focusing on versions
"""
- __OptDict = {
- "version_std": "version_std",
- "formated_output": "formated_output",
- "output_format": "output_format",
- "ignore_unknown_tags": "ignore_unknown_tags",
- }
DefaultInputFormat = "Auto"
- VersionStds = {
+
+ TVersionStds = TypedDict("TVersionStds", {"regex": str, "regex_preversion_num": str, "regex_build_num": str}, total=False)
+
+ VersionStds: dict[str, TVersionStds] = {
"SemVer": {
"regex": r"^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)"
r"(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)"
@@ -333,7 +358,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
"regex_preversion_num": r"(?:\.)(?P(?:\d+(?!\w))+)",
"regex_build_num": r"(?:\.)(?P(?:\d+(?!\w))+)",
},
- "PEP440": {"regex": packaging_VERSION_PATTERN, "Auto": None},
+ "PEP440": {"regex": packaging_VERSION_PATTERN},
}
__versionReseted = False
@@ -357,17 +382,16 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
generic version object
"""
- __OptDict = {
- "bump_type": "bump_type",
- "bump_dev_strategy": "bump_dev_strategy",
- "formated_output": "formated_output",
- }
- DefaultBumpType = "patch"
- BumpTypes = ["major", "minor", "patch", "dev"]
- DefaultBumpDevStrategy = "post"
- BumpDevStrategys = ["post", "pre-patch", "pre-minor", "pre-major"]
+ TBumpTypes = Literal["major", "minor", "patch", "dev"]
+ DefaultBumpType: TBumpTypes = "patch"
+ BumpTypes: set[TBumpTypes] = {"major", "minor", "patch", "dev"}
- version_std: str = "None"
+ TBumpDevStrategies = Literal["post", "pre-patch", "pre-minor", "pre-major"]
+ DefaultBumpDevStrategy: TBumpDevStrategies = "post"
+ BumpDevStrategies: set[TBumpDevStrategies] = {"post", "pre-patch", "pre-minor", "pre-major"}
+
+ TVersionStd = Literal["Auto", "PEP440", "SemVer"]
+ version_std: TVersionStd = "Auto"
major: int = 0
minor: int = 1
patch: int = 0
@@ -377,13 +401,13 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
def __init__(
self,
- version_std,
- major=0,
- minor=1,
- patch=0,
- pre_count=0,
- post_count=0,
- raw="0.1.0",
+ version_std: TVersionStd = "Auto",
+ major: int = 0,
+ minor: int = 1,
+ patch: int = 0,
+ pre_count: int = 0,
+ post_count: int = 0,
+ raw: str = "0.1.0",
): # pylint: disable=R0913
self.version_std = version_std
self.major = major
@@ -394,7 +418,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
self.raw = raw
@classmethod
- def _getBumpDevStrategy(cls, **kwargs) -> str:
+ def _getBumpDevStrategy(cls, **kwargs: Unpack[TKwargs]) -> str:
"""
get selected bump_dev_strategy
Keyword Arguments:
@@ -402,16 +426,17 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
Kwargs given bump_dev_strategy or the default one.
"""
- BumpDevStrategy = cls.DefaultBumpDevStrategy
- if cls.__OptDict["bump_dev_strategy"] in kwargs:
- if kwargs[cls.__OptDict["bump_dev_strategy"]] in cls.BumpDevStrategys:
- BumpDevStrategy = kwargs[cls.__OptDict["bump_dev_strategy"]]
+ BumpDevStrategy: str = cls.DefaultBumpDevStrategy
+
+ if kwargs and ("bump_dev_strategy" in kwargs):
+ if kwargs["bump_dev_strategy"] in cls.BumpDevStrategies:
+ BumpDevStrategy = kwargs["bump_dev_strategy"]
else:
- raise gitversionhelper.wrongArguments(f"invalid {cls.__OptDict['bump_type']} requested")
+ raise gitversionhelper.wrongArguments(f"invalid {'bump_type'} requested")
return BumpDevStrategy
@classmethod
- def _getBumpType(cls, **kwargs) -> str:
+ def _getBumpType(cls, **kwargs: Unpack[TKwargs]) -> str:
"""
get selected bump_type
Keyword Arguments:
@@ -419,15 +444,17 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
Kwargs given bump_type or the default one.
"""
- BumpType = cls.DefaultBumpType
- if cls.__OptDict["bump_type"] in kwargs:
- if kwargs[cls.__OptDict["bump_type"]] in cls.BumpTypes:
- BumpType = kwargs[cls.__OptDict["bump_type"]]
+ BumpType: str = cls.DefaultBumpType
+ if "bump_type" in kwargs:
+ if kwargs["bump_type"] in cls.BumpTypes:
+ BumpType = kwargs["bump_type"]
else:
- raise gitversionhelper.wrongArguments(f"invalid {cls.__OptDict['bump_type']} requested")
+ raise gitversionhelper.wrongArguments(f"invalid {'bump_type'} requested")
return BumpType
- def bump(self, amount: int = 1, **kwargs) -> gitversionhelper.version.MetaVersion | str: # pylint: disable=R0912
+ def bump(
+ self, amount: int = 1, **kwargs: Unpack[TKwargs]
+ ) -> gitversionhelper.version.MetaVersion | str: # pylint: disable=R0912
"""
bump the version to the next one
Keyword Arguments:
@@ -436,8 +463,11 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
the bumped version
"""
- BumpType = self._getBumpType(**kwargs)
+
+ BumpType: str = self._getBumpType(**kwargs)
+
BumpDevStrategy = self._getBumpDevStrategy(**kwargs)
+
_v = copy(self)
if BumpType == "dev":
@@ -473,13 +503,14 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
_v.patch = _v.patch + amount
_v.pre_count = 0
_v.post_count = 0
+
_v.raw = _v.doFormatVersion(**kwargs)
- if (self.__OptDict["formated_output"] in kwargs) and (kwargs[self.__OptDict["formated_output"]] is True):
+ if ("formated_output" in kwargs) and (kwargs["formated_output"] is True):
return _v.doFormatVersion(**kwargs)
return _v
- def doFormatVersion(self, **kwargs) -> str:
+ def doFormatVersion(self, **kwargs: Unpack[TKwargs]) -> str:
"""
output a formated version string
Keyword Arguments:
@@ -490,7 +521,7 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return gitversionhelper.version.doFormatVersion(self, **kwargs)
@classmethod
- def _getVersionStd(cls, **kwargs) -> str:
+ def _getVersionStd(cls, **kwargs: Unpack[TKwargs]) -> gitversionhelper.version.MetaVersion.TVersionStd:
"""
get selected version_std
Keyword Arguments:
@@ -498,16 +529,16 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
Kwargs given version_std or the default one.
"""
- VersionStd = cls.DefaultInputFormat
- if cls.__OptDict["version_std"] in kwargs:
- if kwargs[cls.__OptDict["version_std"]] in cls.VersionStds:
- VersionStd = kwargs[cls.__OptDict["version_std"]]
+ VersionStd: str = cls.DefaultInputFormat
+ if "version_std" in kwargs:
+ if kwargs["version_std"] in cls.VersionStds:
+ VersionStd = kwargs["version_std"]
else:
- raise gitversionhelper.wrongArguments(f"invalid {cls.__OptDict['version_std']} requested")
- return VersionStd
+ raise gitversionhelper.wrongArguments(f"invalid {'version_std'} requested")
+ return cast(gitversionhelper.version.MetaVersion.TVersionStd, VersionStd)
@classmethod
- def getCurrentVersion(cls, **kwargs) -> MetaVersion | str:
+ def getCurrentVersion(cls, **kwargs: Unpack[TKwargs]) -> gitversionhelper.version.MetaVersion | str:
"""
get the current version or bump depending of repository state
Keyword Arguments:
@@ -521,30 +552,33 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
"""
if gitversionhelper.repository.isDirty() is not False:
raise gitversionhelper.repository.repositoryDirty("The repository is dirty and a current version can not be generated.")
+
saved_kwargs = copy(kwargs)
if "formated_output" in kwargs:
del saved_kwargs["formated_output"]
- _v = cls.getLastVersion(**saved_kwargs)
+ _v = cast(gitversionhelper.version.MetaVersion, cls.getLastVersion(**saved_kwargs))
if not cls.__versionReseted:
amount = gitversionhelper.tag.getDistanceFromTag(_v.raw, **kwargs)
- _v = _v.bump(amount, **saved_kwargs)
+ _v = cast(gitversionhelper.version.MetaVersion, _v.bump(amount, **saved_kwargs))
- if (cls.__OptDict["formated_output"] in kwargs) and (kwargs[cls.__OptDict["formated_output"]] is True):
+ if ("formated_output" in kwargs) and (kwargs["formated_output"] is True):
return _v.doFormatVersion(**kwargs)
return _v
@classmethod
- def getCurrentFormatedVersion(cls, **kwargs) -> str:
+ def getCurrentFormatedVersion(cls, **kwargs: Unpack[TKwargs]) -> str:
"""
Same as getCurrentVersion() with formated_output kwarg activated
"""
kwargs["formated_output"] = True
- return cls.getCurrentVersion(**kwargs)
+ return cast(str, cls.getCurrentVersion(**kwargs))
@classmethod
- def _parseTag(cls, tag, **kwargs): # pylint: disable=R0914, R0912, R0915
+ def _parseTag(
+ cls, tag: str, **kwargs: Unpack[TKwargs]
+ ) -> gitversionhelper.version.MetaVersion: # pylint: disable=R0914, R0912, R0915
"""get the last version from tags
Arguments:
tag: the tag to be parsed
@@ -554,7 +588,8 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
the last version
"""
- VersionStd = cls._getVersionStd(**kwargs)
+ _m: Optional[re.Match[str]]
+ VersionStd: gitversionhelper.version.MetaVersion.TVersionStd = cls._getVersionStd(**kwargs)
bAutoVersionStd = False
if VersionStd == "Auto":
bAutoVersionStd = True
@@ -565,14 +600,12 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
re.VERBOSE | re.IGNORECASE,
)
_m = re.match(_r, tag)
- if not _m:
+ if _m is None:
pass
else:
- major, minor, patch = (
- int(_m.group("major")),
- int(_m.group("minor")),
- int(_m.group("patch")),
- )
+ major = int(_m.group("major"))
+ minor = int(_m.group("minor"))
+ patch = int(_m.group("patch"))
pre_count = 0
if _pre := _m.group("prerelease"):
@@ -596,19 +629,25 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
re.VERBOSE | re.IGNORECASE,
)
_m = re.match(_r, tag)
- if not _m:
+ if _m is None:
pass
else:
- ver = _m.group("release").split(".")
- ver += ["0"] * (3 - len(ver))
- ver[0] = int(ver[0])
- ver[1] = int(ver[1])
- ver[2] = int(ver[2])
- major, minor, patch = tuple(ver)
- pre_count = int(_m.group("pre_n")) if _m.group("pre_n") else 0
- post_count = int(_m.group("post_n2")) if _m.group("post_n2") else 0
- bFound = True
- VersionStd = "PEP440"
+ res: str = _m.group("release")
+ if isinstance(res, str):
+
+ ver = res.split(".")
+ ver += ["0"] * (3 - len(ver))
+
+ ver_int: List[int] = [0, 0, 0]
+ ver_int[0] = int(ver[0])
+ ver_int[1] = int(ver[1])
+ ver_int[2] = int(ver[2])
+ major, minor, patch = tuple(ver_int)
+
+ pre_count = int(_m.group("pre_n")) if _m.group("pre_n") else 0
+ post_count = int(_m.group("post_n2")) if _m.group("post_n2") else 0
+ bFound = True
+ VersionStd = "PEP440"
if not bFound:
raise gitversionhelper.version.noValidVersion("no valid version found in tags")
@@ -618,7 +657,9 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
return cls.MetaVersion(VersionStd, major, minor, patch, pre_count, post_count, tag)
@classmethod
- def getLastVersion(cls, **kwargs) -> MetaVersion | str: # pylint: disable=R0914, R0912, R0915
+ def getLastVersion(
+ cls, **kwargs: Unpack[TKwargs]
+ ) -> gitversionhelper.version.MetaVersion | str: # pylint: disable=R0914, R0912, R0915
"""get the last version from tags
Keyword Arguments:
version_std(str): the given version_std (can be None)
@@ -628,20 +669,20 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
Returns:
the last version
"""
- lastTag = cls.MetaVersion.raw
+ lastTag: str = cls.MetaVersion.raw
cls.__versionReseted = False
try:
- lastTag = gitversionhelper.tag.getLastTag(**kwargs)
+ lastTag = cast(str, gitversionhelper.tag.getLastTag(**kwargs))
except gitversionhelper.tag.tagNotFound:
logging.warning("tag not found, reseting versionning")
cls.__versionReseted = True
- _v = None
+ _v: Optional[gitversionhelper.version.MetaVersion] = None
try:
_v = cls._parseTag(lastTag, **kwargs)
except gitversionhelper.version.noValidVersion as _ex:
- if (cls.__OptDict["ignore_unknown_tags"] in kwargs) and (kwargs[cls.__OptDict["ignore_unknown_tags"]] is True):
- tags = gitversionhelper.tag.getTags(sort="taggerdate", **kwargs)
+ if ("ignore_unknown_tags" in kwargs) and (kwargs["ignore_unknown_tags"] is True):
+ tags = gitversionhelper.tag.getTags(Sort="taggerdate", **kwargs)
_v = None
for _tag in tags:
try:
@@ -652,12 +693,12 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
if _v is None:
raise gitversionhelper.version.noValidVersion() from _ex
- if (cls.__OptDict["formated_output"] in kwargs) and (kwargs[cls.__OptDict["formated_output"]] is True):
+ if ("formated_output" in kwargs) and (kwargs["formated_output"] is True):
return _v.doFormatVersion(**kwargs)
return _v
@classmethod
- def doFormatVersion(cls, inputversion: MetaVersion, **kwargs) -> str:
+ def doFormatVersion(cls, inputversion: MetaVersion, **kwargs: Unpack[TKwargs]) -> str:
"""
output a formated version string
Keyword Arguments:
@@ -679,8 +720,8 @@ class gitversionhelper: # pylint: disable=too-few-public-methods
pre_count = inputversion.pre_count
patch = inputversion.patch
- if cls.__OptDict["output_format"] in kwargs:
- OutputFormat = kwargs[cls.__OptDict["output_format"]]
+ if "output_format" in kwargs:
+ OutputFormat = kwargs["output_format"]
if OutputFormat is None:
OutputFormat = "{major}.{minor}.{patch}{revpattern}{revcount}"
diff --git a/test/test_gitversionhelper.py b/test/test_gitversionhelper.py
index 137ed34..17f8dfd 100644
--- a/test/test_gitversionhelper.py
+++ b/test/test_gitversionhelper.py
@@ -730,9 +730,9 @@ class Test_gitversionhelper(unittest.TestCase):
with self.assertRaises(pygitversionhelper.gitversionhelper.version.PreAndPostVersionUnsupported):
pygitversionhelper.gitversionhelper.version._parseTag("0.0.1.pre1.post1")
- def test_defect__git__wrongargument_sortargs(self):
+ def test_defect__git__wrongargument_Sortargs(self):
with self.assertRaises(pygitversionhelper.gitversionhelper.wrongArguments):
- pygitversionhelper.gitversionhelper.tag.getTags(sort="toto")
+ pygitversionhelper.gitversionhelper.tag.getTags(Sort="toto")
def test_defect__git__notagfound(self):
with open("demofile.txt", "w+t") as tmpFile: