Skip to content

Commit

Permalink
MAINT: upgrade syntax to Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Aug 7, 2024
1 parent 6889870 commit c3a1023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/pwa_pages/repo/_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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]
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions src/pwa_pages/repo/_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)

0 comments on commit c3a1023

Please sign in to comment.