Update the pre-commit hooks

This commit is contained in:
Dunedan 2025-01-09 16:35:31 +01:00
parent 5aa96cd282
commit a92a4ff45c
No known key found for this signature in database
GPG key ID: 885B16854284E0B2
7 changed files with 22 additions and 26 deletions

View file

@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-executables-have-shebangs
@ -19,7 +19,7 @@ repos:
^binaries/data/mods/public/maps/.*\.xml
)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.9.0
hooks:
- id: ruff
args:
@ -41,7 +41,7 @@ repos:
files: ^binaries/
exclude: (^binaries/data/mods/(mod|public)/art/.*\.xml|\.dae$)
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
rev: v3.10.0-2
hooks:
- id: shfmt
args:
@ -53,7 +53,7 @@ repos:
hooks:
- id: shellcheck
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.43.0
hooks:
- id: markdownlint
exclude: |

View file

@ -195,7 +195,7 @@ class CheckRefs:
self.deps.append((fp, Path(f"art/actors/{template[len(actor_prefix) :]}")))
elif template.startswith(resource_prefix):
self.deps.append(
(fp, Path(f"simulation/templates/{template[len(resource_prefix):]}.xml"))
(fp, Path(f"simulation/templates/{template[len(resource_prefix) :]}.xml"))
)
else:
self.deps.append((fp, Path(f"simulation/templates/{template}.xml")))

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python3
import sys
from os import chdir
from pathlib import Path
from re import split
from subprocess import run
from sys import exit
from scriptlib import SimulTemplateEntity, find_files, warn
@ -58,7 +58,7 @@ def main():
dot_f.write(f'"{f}" -> "{training_queue}" [color=blue];\n')
dot_f.write("}\n")
if run(["dot", "-V"], capture_output=True, check=False).returncode == 0:
exit(
sys.exit(
run(
["dot", "-Tpng", "creation.dot", "-o", "creation.png"], text=True, check=False
).returncode

View file

@ -163,11 +163,11 @@ def generate_font(outname, ttf_names, loadopts, size, renderstyle, dsizes):
# Output the .fnt file with all the glyph positions etc
with open(f"{outname}.fnt", "w", encoding="utf-8") as fnt:
fnt.write("101\n")
fnt.write("%d %d\n" % (w, h))
fnt.write(f"{w} {h}\n")
fnt.write("%s\n" % ("rgba" if "colour" in renderstyle else "a"))
fnt.write("%d\n" % len(glyphs))
fnt.write("%d\n" % linespacing)
fnt.write("%d\n" % charheight)
fnt.write(f"{len(glyphs)}\n")
fnt.write(f"{linespacing}\n")
fnt.write(f"{charheight}\n")
for g in glyphs:
x0 = g.x0
y0 = g.y0
@ -181,8 +181,7 @@ def generate_font(outname, ttf_names, loadopts, size, renderstyle, dsizes):
y0 += charheight / 3
fnt.write(
"%d %d %d %d %d %d %d %d\n"
% (ord(g.char), g.pos.x, h - g.pos.y, g.w, g.h, -x0, y0, g.xadvance)
f"{ord(g.char)} {g.pos.x} {h - g.pos.y} {g.w} {g.h} {-x0} {g.xadvance}\n"
)
return

View file

@ -123,11 +123,6 @@ class Extractor:
class JavascriptExtractor(Extractor):
"""Extract messages from JavaScript source code."""
empty_msgid_warning = (
'%s: warning: Empty msgid. It is reserved by GNU gettext: gettext("") '
"returns the header entry with meta information, not the empty string."
)
def extract_javascript_from_file(self, file_object):
funcname = message_lineno = None
messages = []
@ -282,11 +277,13 @@ class JavascriptExtractor(Extractor):
first_msg_index = spec[0] - 1
if not messages[first_msg_index]:
# An empty string msgid isn't valid, emit a warning
where = "%s:%i" % (
hasattr(file_object, "name") and file_object.name or "(unknown)",
lineno,
fname = (hasattr(file_object, "name") and file_object.name) or "(unknown)"
print(
f"{fname}:{lineno}: warning: Empty msgid. It is reserved by GNU gettext: "
'gettext("") returns the header entry with meta information, '
"not the empty string.",
file=sys.stderr,
)
print(self.empty_msgid_warning % where, file=sys.stderr)
continue
messages = tuple(msgs)

View file

@ -52,8 +52,8 @@ def warn_about_untouched_mods():
if untouched_mods:
print("Warning: No messages were extracted from the following mods:")
for mod in untouched_mods:
print(f"{mod}: {untouched_mods[mod]}")
for mod_folder, error in untouched_mods.items():
print(f"{mod_folder}: {error}")
print(
""
f"For this script to extract messages from a mod folder, this mod folder must contain "
@ -83,7 +83,7 @@ def generate_pot(template_settings, root_path):
options = rule.get("options", {})
extractor_class = getattr(
import_module("i18n_helper.extractors"), f'{rule["extractor"].title()}Extractor'
import_module("i18n_helper.extractors"), f"{rule['extractor'].title()}Extractor"
)
extractor = extractor_class(input_root_path, rule["filemasks"], options)
format_flag = None

View file

@ -395,7 +395,7 @@ def write_coloured_diff(file, diff, is_changed):
if diff == 0:
rgb_str = "200,200,200"
elif is_advantageous and diff > 0 or (not is_advantageous) and diff < 0:
elif (is_advantageous and diff > 0) or (not is_advantageous and diff < 0):
rgb_str = "180,0,0"
else:
rgb_str = "0,150,0"