Enable flake8-annotations linting rules (#267)

See https://docs.astral.sh/ruff/rules/#flake8-annotations-ann.
This commit is contained in:
Marc Wrobel
2023-12-30 10:38:17 +01:00
parent 0e8fe135e4
commit f49e3dff15
12 changed files with 51 additions and 47 deletions

View File

@@ -8,7 +8,7 @@ class Git:
"""Git cli wrapper
"""
def __init__(self, url: str):
def __init__(self, url: str) -> None:
self.url: str = url
self.repo_dir: Path = Path(f"~/.cache/git/{sha1(url.encode()).hexdigest()}").expanduser()
@@ -22,7 +22,7 @@ class Git:
except ChildProcessError as ex:
raise RuntimeError(f"Failed to run '{cmd}': {ex}") from ex
def setup(self, bare: bool = False):
def setup(self, bare: bool = False) -> None:
"""Creates the repository path and runs:
git init
git remote add origin $url
@@ -34,7 +34,7 @@ class Git:
self._run(f"remote add origin {self.url}")
# See https://stackoverflow.com/a/65746233/374236
def list_tags(self):
def list_tags(self) -> list[tuple[str, str]]:
"""Fetch and return tags matching the given`pattern`"""
# See https://stackoverflow.com/a/65746233/374236
self._run("config --local extensions.partialClone true")
@@ -44,7 +44,7 @@ class Git:
tags_with_date = self._run("tag --list --format='%(refname:strip=2) %(creatordate:short)'")
return [tag_with_date.split(" ") for tag_with_date in tags_with_date]
def list_branches(self, pattern: str):
def list_branches(self, pattern: str) -> list[str]:
"""Uses ls-remote to fetch the branch names
`pattern` uses fnmatch style globbing
"""
@@ -56,7 +56,7 @@ class Git:
return [line.split("\t")[1][11:] for line in lines if "\t" in line]
def checkout(self, branch: str, file_list: list[str] = None):
def checkout(self, branch: str, file_list: list[str] = None) -> None:
"""Checks out a branch
If `file_list` is given, sparse-checkout is used to save bandwidth
and only download the given files