Skip to content

Commit cd1704d

Browse files
committed
release-tool: run against Python linters
1 parent 27d3ca7 commit cd1704d

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

release-tool

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# tool to help make consistent Cute Chess releases
44

5+
import os
6+
import re
57
import subprocess
68
import sys
79
import tempfile
8-
import os
9-
import re
1010

1111

1212
def usage() -> None:
@@ -20,24 +20,36 @@ def error(msg: str) -> None:
2020

2121

2222
def validate_version(ver: str) -> bool:
23-
return re.match('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', ver)
23+
return re.match("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)", ver) is not None
2424

2525

2626
def git_dir_exists() -> bool:
2727
return os.path.isdir(f"{os.getcwd()}/.git")
2828

2929

3030
def current_branch() -> str:
31-
return subprocess.run(["git", "branch", "--show-current"],
32-
stdout=subprocess.PIPE).stdout.decode().strip()
31+
return (
32+
subprocess.run(["git", "branch", "--show-current"], stdout=subprocess.PIPE)
33+
.stdout.decode()
34+
.strip()
35+
)
3336

3437

3538
def release_exists(rel: str) -> bool:
36-
return len(subprocess.run(["git", "tag", "-l", f"v{rel}"],
37-
stdout=subprocess.PIPE).stdout.decode().strip()) != 0
39+
return (
40+
len(
41+
subprocess.run(["git", "tag", "-l", f"v{rel}"], stdout=subprocess.PIPE)
42+
.stdout.decode()
43+
.strip()
44+
)
45+
!= 0
46+
)
47+
3848

3949
def working_tree_clean() -> bool:
40-
return subprocess.run(["git", "diff-index", "--quiet", "HEAD", "--"]).returncode == 0
50+
return (
51+
subprocess.run(["git", "diff-index", "--quiet", "HEAD", "--"]).returncode == 0
52+
)
4153

4254

4355
def pull_remote_changes() -> bool:
@@ -54,8 +66,12 @@ def update_version_file(new_version: str) -> bool:
5466
# before entering to this function, working tree is clean
5567
# and ".version" should be already in the repo so
5668
# "commit -a" should be safe
57-
return subprocess.run(["git", "commit", "-a", "-m",
58-
f"version {new_version}"]).returncode == 0
69+
return (
70+
subprocess.run(
71+
["git", "commit", "-a", "-m", f"version {new_version}"]
72+
).returncode
73+
== 0
74+
)
5975

6076

6177
if __name__ == "__main__":
@@ -65,7 +81,9 @@ if __name__ == "__main__":
6581
new_version = sys.argv[1]
6682

6783
if not validate_version(new_version):
68-
error(f"{new_version} does not conform to the semver standard MAJOR.MINOR.PATCH")
84+
error(
85+
f"{new_version} does not conform to the semver standard MAJOR.MINOR.PATCH"
86+
)
6987

7088
if not git_dir_exists():
7189
error("'.git' does not exist; move to the source root")

0 commit comments

Comments
 (0)