summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorLaserEyess <lasereyess@users.noreply.github.com>2024-02-24 15:57:54 -0500
committersfan5 <sfan5@live.de>2024-02-25 14:28:05 +0100
commit914e56d8455748b1563b23fe0663be646d7c5832 (patch)
treedad2b38b448baf58093872cbebdf97e3fabda589 /ci
parent3e8d69e3e86fbca6719028ffda9b75918b4c575f (diff)
downloadmpv-914e56d8455748b1563b23fe0663be646d7c5832.tar.bz2
mpv-914e56d8455748b1563b23fe0663be646d7c5832.tar.xz
ci: fix typing in lint-commit-msg.py
1. Explicitly add typing to lint_rules 2. Fix return type for get_commit_range() 3. Fix no-return path with get_commit_range()
Diffstat (limited to 'ci')
-rwxr-xr-xci/lint-commit-msg.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/ci/lint-commit-msg.py b/ci/lint-commit-msg.py
index 0bfad08a3a..10c7d1886c 100755
--- a/ci/lint-commit-msg.py
+++ b/ci/lint-commit-msg.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
import os, sys, json, subprocess, re
+from typing import Dict, Tuple, Callable, Optional
def call(cmd) -> str:
sys.stdout.flush()
ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, text=True)
return ret.stdout
-lint_rules = {}
+lint_rules: Dict[str, Tuple[Callable, str]] = {}
def lint_rule(description: str):
def f(func):
@@ -14,7 +15,7 @@ def lint_rule(description: str):
lint_rules[func.__name__] = (func, description)
return f
-def get_commit_range() -> str:
+def get_commit_range() -> Optional[str]:
if len(sys.argv) > 1:
return sys.argv[1]
# https://github.com/actions/runner/issues/342#issuecomment-590670059
@@ -28,6 +29,7 @@ def get_commit_range() -> str:
return event["before"] + "..." + event["after"]
elif event_name == "pull_request":
return event["pull_request"]["base"]["sha"] + ".." + event["pull_request"]["head"]["sha"]
+ return None
def do_lint(commit_range: str) -> bool:
commits = call(["git", "log", "--pretty=format:%h %s", commit_range]).splitlines()