From c3a102349a391c4ad8c6aef6fbb9d1577109ae70 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:08:19 +0200 Subject: [PATCH] MAINT: upgrade syntax to Python 3.8 --- src/pwa_pages/repo/_github.py | 12 ++++++------ src/pwa_pages/repo/_gitlab.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pwa_pages/repo/_github.py b/src/pwa_pages/repo/_github.py index 0347206d..d868c14d 100644 --- a/src/pwa_pages/repo/_github.py +++ b/src/pwa_pages/repo/_github.py @@ -15,7 +15,7 @@ from github.Commit import Commit -@lru_cache() +@lru_cache def get_github_repo(url: str) -> GithubRepository: github = __get_github() repo_name = extract_github_repo_name(url) @@ -25,7 +25,7 @@ def get_github_repo(url: str) -> GithubRepository: return github.get_repo(repo_name) -@lru_cache() +@lru_cache def extract_github_repo_name(url: str) -> str: github_url = "https://github.com" match = re.match(rf"^{github_url}/([^/]+)/([^/]+).*$", url) @@ -34,7 +34,7 @@ def extract_github_repo_name(url: str) -> str: return f"{match[1]}/{match[2]}" -@lru_cache() +@lru_cache def get_first_commit_date(repo: GithubRepository) -> datetime: commits = repo.get_commits().reversed first_commit: Commit = commits[0] @@ -45,7 +45,7 @@ def get_first_commit_date(repo: GithubRepository) -> datetime: return parse_date(timestamp) -@lru_cache() +@lru_cache def get_latest_commit_date(repo: GithubRepository) -> datetime: default_branch = repo.default_branch latest_commit = repo.get_commit(default_branch) @@ -66,7 +66,7 @@ def get_last_modified(repo: GithubRepository) -> datetime: return parse_date(repo.last_modified) -@lru_cache() +@lru_cache def get_languages(repo: GithubRepository) -> dict[str, float]: languages = repo.get_languages() total_lines = sum(languages.values()) @@ -75,7 +75,7 @@ def get_languages(repo: GithubRepository) -> dict[str, float]: } -@lru_cache() +@lru_cache def __get_github(token: str | None = None) -> Github: if token is None: token = os.environ.get("GITHUB_TOKEN") diff --git a/src/pwa_pages/repo/_gitlab.py b/src/pwa_pages/repo/_gitlab.py index 2b7b3c6c..64dbd620 100644 --- a/src/pwa_pages/repo/_gitlab.py +++ b/src/pwa_pages/repo/_gitlab.py @@ -14,7 +14,7 @@ from gitlab.v4.objects import ProjectCommitManager -@lru_cache() +@lru_cache def get_gitlab_repo(server_url: str, project_path: str) -> GitlabProject: gitlab = __get_gitlab(server_url) return gitlab.projects.get(project_path) @@ -29,7 +29,7 @@ def split_gitlab_repo_url(url: str) -> tuple[str, str] | None: return server_url, project_path -@lru_cache() +@lru_cache def get_first_commit_date(repo: GitlabProject) -> datetime: commits: ProjectCommitManager = repo.commits all_commits = commits.list(all=True) @@ -39,7 +39,7 @@ def get_first_commit_date(repo: GitlabProject) -> datetime: return parse_date(commit_info["created_at"]) -@lru_cache() +@lru_cache def get_latest_commit_date(repo: GitlabProject) -> datetime: default_branch = repo.attributes["default_branch"] commits: ProjectCommitManager = repo.commits @@ -53,6 +53,6 @@ def get_last_modified(repo: GitlabProject) -> datetime: return parse_date(date_str) -@lru_cache() +@lru_cache def __get_gitlab(url: str) -> Gitlab: return Gitlab(url)