Skip to content

Commit

Permalink
build: type cleanups in python ci scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexogeny committed Jul 31, 2024
1 parent b8c53b0 commit f80a341
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions ci/common.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import re
import subprocess
from typing import List, Literal, Union

LastVersion = Union[str, None]
CommitList = List[str]
Suffix = Union[Literal["alpha"], Literal["beta"], None]

def get_last_version() -> str | None:

def get_last_version():
result = subprocess.run(
["git", "describe", "--tags", "--abbrev=0"], stdout=subprocess.PIPE, text=True
)
Expand All @@ -11,7 +16,7 @@ def get_last_version() -> str | None:
return result.stdout.strip()


def get_commits_since_last_version(last_version: str | None) -> list[str]:
def get_commits_since_last_version(last_version: LastVersion):
if last_version:
result = subprocess.run(
["git", "log", f"{last_version}..HEAD", "--pretty=format:%s"],
Expand All @@ -36,7 +41,7 @@ def update_pyproject_toml(version):
file.write(content)


def determine_next_version(last_version: str | None, commits: list[str]) -> str:
def determine_next_version(last_version: LastVersion, commits: CommitList):
if not last_version:
last_version = "v0.1.0"

Expand Down
11 changes: 8 additions & 3 deletions ci/generate_release_notes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from common import get_commits_since_last_version, get_last_version
from common import CommitList, Suffix, get_commits_since_last_version, get_last_version


def categorize_commits(commits):
def categorize_commits(commits: CommitList):
major_commits = []
minor_commits = []
patch_commits = []
Expand All @@ -23,7 +23,12 @@ def categorize_commits(commits):
return major_commits, minor_commits, patch_commits, suffix


def generate_release_notes(major_commits, minor_commits, patch_commits, suffix):
def generate_release_notes(
major_commits: CommitList,
minor_commits: CommitList,
patch_commits: CommitList,
suffix: Suffix,
):
notes = []

if suffix:
Expand Down

0 comments on commit f80a341

Please sign in to comment.