This refactors the script for cleaning the translations to get the
same result by doing less. This is achieved by the following changes:
- Use glob-patterns for finding the files to clean more efficiently,
without the need to exclude collected files again.
- Only write files which are supposed to be modified (previously all
portable object files did get rewritten by this script, no matter if
it did change something or not).
- Stop searching for sections in files to clean up, once they are
already passed.
This commit enables a bunch of unrelated ruff rules, which only require
minimal changes to the code base to enable them.
The rules enabled by this commit are:
- check the use of datetime objects without timezone (DTZ005)
- check the performance of try-except in loops (PERF203)
- check the number of function arguments (PLR0913)
- check for mutable class defaults (RUF012)
- check for the use of secure hashing algorithms (S324)
- check for raising base exceptions (TRY002)
- check for raising other exceptions where TypeErrors should be raised
(TRY004)
This ensures the same Python target version used for `ruff format`
is used for `ruff check` as well. It also allows ruff, even if it's not
run through pre-commit, to use the correct target Python version.
Previously when checking if two SPIR-V shaders are identical the
hashs of their file content would be compared and afterwards their
(unhashed) file contents as well. Comparing the file contents isn't
necessary, as the hash function used is a cryptographic one, which
guarantees the hash can be used as a representative of the hashed data.
While the desired options for indent size and style are Python's
defaults, let's make it explicit by specifying it in the EditorConfig.
As part of this, this also removes unnecessary inline formatting options
for Python files.
This simplifies the XML parsing, by iterating over the DOM tree only
once. Curiously this doesn't result in significant performance gains.
As the keywords are now found in the order they appear in the
document instead of the order they are mentioned in messages.json, the
order of a few strings in the PO-templates changes caused by the changes
in this commit.
This simplifies the code structure, by removing the extractors package,
which only contained a single module, the extractors module. This module
is now located in the i18n_helper package.
The ini-file extractor has been broken since the transition to Python 3
and nobody noticed, because it isn't used nowadays. Therefore, let's
remove it.
This increases the performance of updating the PO-templates
significantly by adding a cache for the building of mask patterns. In
non-representative tests it increased the performance of updating the
PO-templates by >25%.
This increases the number of workers to use when fetching translations
from Transifex from 5 (the default) to 12. While the Transifex CLI
allows up to 20 workers, using more workers results in frequent request
throttling, which hurts performance more than it improves it.
- Silence a MSVC warning in vulkan.cpp, refs #6987
- Document the patching of gl.h for macOS, from r26094
- Fix shellcheck warnings in the generation script
The new script merges existing scripts for downloading translations and
SPIR-V shaders, and also exports game binaries from the latest nightly
build into the git repo.
This allows contributors, especially artists, to obtain a working build
of the game without learning how to build the game for Windows, refs #1814.
The fontbuilder2 README file was already partially formatted with
Markdown, but didn't indicate that via its file extension. This commit
changes that and improves the formatting of the README itself.
This enables some ruff rules for docstrings and comments. The idea is to
not enforce the presence of docstrings, but to ensure they are properly
formatted if they're present.
For comments this adds checks that they don't contain code and verify
the formatting of comments with "TODO" tags.
As part of this, some commented out code which hasn't been touch in the
past 10 years gets removed as well.
The rules enabled enabled by this are:
- check formatting of existing docstrings (D200-)
- check comments for code (ERA)
- check formatting of TODO tags (TD001, TD004-)
This explicitly uses UTF-8 encoding when reading or writing files with
Python. This is necessary as the default locale varies between
operating systems.
This enables ruff rules which check for code which can be simplified to
improve readability.
The additionally rules getting enabled by this are:
- remove unnecessary nesting of if-statements (SIM102)
- use contextlib.suppress() for no-op exception handling (SIM105)
- use enumerate() for counting in loops (SIM113)
- use context managers for opening files (SIM115)
This enables some ruff rules to check for ambiguous and dead Python
code, which might cause unintended side-effects.
The enabled rules are:
- a bunch of rules related to shadowing of builtin structures (A)
- a bunch of rules checking for unused arguments (ARG)
- a rule checking for useless expressions (B018)
- a rule checking for unbound loop variables (B023)
- a rule checking redefined function parameters (PLR1704)
This updates shell scripts to use a consistent style that can be enforced
via pre-commit hook.
As for choosing tabs over spaces, some arguments are:
- tabs can help people with visual impairment
- tabs allow for indenting heredocs in bash
- tabs are the default for the tool shfmt
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This removes the executable bits from files which aren't supposed to
have them.
Also removes shebangs for files which aren't supposed to be executable.