Skip to content

Commit bd7c059

Browse files
rffontenellehugovkezio-melotti
authored
Apply suggestions from code review
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
1 parent 541c7a5 commit bd7c059

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
os: ["ubuntu-latest", "windows-latest"]
5858
# Test minimum supported and latest stable from 3.x series
59-
python-version: ["3.8", "3"]
59+
python-version: ["3.9", "3"]
6060
steps:
6161
- uses: actions/checkout@v4
6262
- uses: actions/setup-python@v5

babel_runner.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_project_info() -> dict:
3434
return data["project"]
3535

3636

37-
def extract_messages():
37+
def extract_messages() -> None:
3838
"""Extract messages from all source files into message catalog template"""
3939
Path(PROJECT_DIR, LOCALES_DIR).mkdir(parents=True, exist_ok=True)
4040
project_data = get_project_info()
@@ -61,7 +61,7 @@ def extract_messages():
6161
)
6262

6363

64-
def init_locale(locale: str):
64+
def init_locale(locale: str) -> None:
6565
"""Initialize a new locale based on existing message catalog template"""
6666
pofile = PROJECT_DIR / LOCALES_DIR / locale / "LC_MESSAGES" / f"{DOMAIN}.po"
6767
if pofile.exists():
@@ -71,23 +71,23 @@ def init_locale(locale: str):
7171
subprocess.run(cmd, cwd=PROJECT_DIR, check=True)
7272

7373

74-
def update_catalogs(locale: str):
74+
def update_catalogs(locale: str) -> None:
7575
"""Update translations from existing message catalogs"""
7676
cmd = ["pybabel", "update", "-i", POT_FILE, "-d", LOCALES_DIR]
77-
if locale != "":
77+
if locale:
7878
cmd.extend(["-l", locale])
7979
subprocess.run(cmd, cwd=PROJECT_DIR, check=True)
8080

8181

82-
def compile_catalogs(locale: str):
82+
def compile_catalogs(locale: str) -> None:
8383
"""Compile existing message catalogs"""
8484
cmd = ["pybabel", "compile", "-d", LOCALES_DIR]
85-
if locale != "":
85+
if locale:
8686
cmd.extend(["-l", locale])
8787
subprocess.run(cmd, cwd=PROJECT_DIR, check=True)
8888

8989

90-
def main():
90+
def main() -> None:
9191
parser = argparse.ArgumentParser(description=__doc__)
9292
parser.add_argument(
9393
"command",
@@ -97,16 +97,17 @@ def main():
9797
parser.add_argument(
9898
"-l",
9999
"--locale",
100+
default="",
100101
help="language code (needed for init, optional for update and compile)",
101102
)
102103

103104
args = parser.parse_args()
104-
locale = args.locale if args.locale else ""
105+
locale = args.locale
105106

106107
if args.command == "extract":
107108
extract_messages()
108109
elif args.command == "init":
109-
if locale == "":
110+
if not locale:
110111
parser.error("init requires passing the --locale option")
111112
init_locale(locale)
112113
elif args.command == "update":

0 commit comments

Comments
 (0)