Contributing to Weblate modules#
Besides the main repository, Weblate consists of several Python modules. All these follow same structure and this documentation covers them all.
For example, this covers:
wlc, Python client library, see Weblate Client
translation-finder, used to discover translatable files in the repository
language-data, language definitions for Weblate, see Language definitions
Coding guidelines#
Any code for Weblate should be written with Security by Design Principles in mind.
Any code should come with documentation explaining the behavior. Don’t forget documenting methods, complex code blocks, or user visible features.
Any new code should utilize PEP 484 type hints. We’re not checking this in our CI yet as existing code does not yet include them.
Running tests#
The tests are executed using py.test. First you need to install test requirements:
pip install -r requirements-test.txt
You can then execute the testsuite in the repository checkout:
py.test
See also
The CI integration is very similar to Weblate testsuite and continuous integration.
Coding standard and linting the code#
The code should follow PEP-8 coding guidelines and should be formatted using black code formatter.
To check the code quality, you can use flake8, the recommended
plugins are listed in .pre-commit-config.yaml
and its configuration is
placed in setup.cfg
.
The easiest approach to enforce all this is to install pre-commit. The
repository contains configuration for it to verify the committed files are sane.
After installing it (it is already included in the
requirements-lint.txt
) turn it on by running pre-commit install
in
Weblate checkout. This way all your changes will be automatically checked.
You can also trigger check manually, to check all files run:
pre-commit run --all
See also