Skip to content

Commit 22dfb90

Browse files
committed
fix(docs): consolidate style documentation
- consistently use uv to install and test - avoid legacy naming for pytest - remove some outdated ignores
1 parent ebc076f commit 22dfb90

7 files changed

Lines changed: 66 additions & 55 deletions

File tree

AGENTS.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ For application-developer workflows and broader product integration guidance, us
2727
`<type>(<optional scope>): <description>`. Common types include `feat`,
2828
`fix`, `docs`, `refactor`, `test`, `ci`, and `chore`. Example:
2929
`fix(translations): handle empty component slug`.
30-
- Include the GPL-3.0-or-later license header in new Python files.
30+
- Keep new project code under GPL-3.0-or-later and include the repository's
31+
usual copyright and SPDX license header in new Python files.
3132

3233
## Documentation expectations
3334

@@ -72,15 +73,18 @@ For application-developer workflows and broader product integration guidance, us
7273
- After syncing, prefer `uv run ...` for subsequent commands so they use the
7374
virtual environment created in `.venv`. If needed, you can also activate it
7475
with `source .venv/bin/activate` or invoke tools from `.venv/bin/`.
75-
- Prefer `prek run --all-files` as the primary linting/formatting command because
76+
- Prefer `uv run prek run --all-files` as the primary linting/formatting command because
7677
it runs the repository's configured pre-commit framework checks.
7778
- `prek` is a third-party reimplementation of the `pre-commit` tool.
78-
- Use `pytest` to run the test suite: `pytest weblate`. On a fresh checkout,
79+
- Use `pytest` to run the test suite: `uv run pytest`. On a fresh checkout,
7980
first follow the local test setup in `docs/contributing/tests.rst`
8081
(`DJANGO_SETTINGS_MODULE=weblate.settings_test`, `collectstatic`, and test
8182
database prerequisites). `scripts/test-database.sh` can be sourced to set up
8283
the database connection variables such as `CI_DB_USER`, `CI_DB_PASSWORD`,
8384
`CI_DB_HOST`, and `CI_DB_PORT`.
84-
- Use `pylint` to lint the Python code: `pylint weblate/`
85-
- Use `mypy` to type check the code: `mypy weblate/`
86-
- All mentioned linting tools MUST pass.
85+
- Use `pylint` to lint the Python code: `uv run pylint weblate/ scripts/`
86+
- Use `mypy` to type check with the same command as CI:
87+
`uv run mypy --show-column-numbers weblate scripts/*.py ./*.py | ./scripts/filter-mypy.sh`.
88+
- New or changed code should not introduce new mypy failures where current
89+
Django typing support makes that practical. Existing non-enforced mypy
90+
findings should not be worsened.

docs/admin/install/source.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ Installing from sources
2424
2525
. ~/weblate-env/bin/activate
2626
uv pip install -e 'weblate-src[all]'
27-
# In case you intentd to run testsuite, install test deps as well:
28-
uv pip install -e 'weblate-src[all,test]'
27+
28+
If you intend to run the testsuite from the source checkout, install the
29+
development dependencies as described in :ref:`local-tests`.
2930

3031
#. Copy :file:`weblate/settings_example.py` to :file:`weblate/settings.py`.
3132

docs/contributing/frontend.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Prerequisites
2828

2929
Before proceeding with an installation, make sure you have the following prerequisites:
3030

31-
- ``Nodejs`` version 14 or higher.
31+
- A supported ``Node.js`` release.
3232
- The ``yarn`` package manager is installed on your system.
3333
- Run ``cd client``.
34-
- Run ``yarn install``.
34+
- Run ``yarn install --check-files``.
3535

3636
Installation
3737
++++++++++++
@@ -88,7 +88,9 @@ Now the library is built and ready for use. To include it follow these steps:
8888
Coding style
8989
------------
9090

91-
Weblate relies on `Biome`_ for formatting and linting the JavaScript and CSS code.
91+
Weblate relies on `Biome`_ for formatting and linting the JavaScript and CSS
92+
code. Django templates are formatted and linted separately by :program:`djade`
93+
and :program:`djlint`.
9294

9395
.. _Biome: https://biomejs.dev/
9496

@@ -102,16 +104,16 @@ function, but there are more complex features available:
102104

103105
.. code-block:: javascript
104106
105-
document.write(gettext('this is to be translated'));
107+
document.write(gettext("this is to be translated"));
106108
107109
var object_count = 1 // or 0, or 2, or 3, ...
108-
s = ngettext('literal for the singular case',
109-
'literal for the plural case', object_count);
110+
s = ngettext("literal for the singular case",
111+
"literal for the plural case", object_count);
110112
111-
fmts = ngettext('There is %s object. Remaining: %s',
112-
'There are %s objects. Remaining: %s', 11);
113+
fmts = ngettext("There is %s object. Remaining: %s",
114+
"There are %s objects. Remaining: %s", 11);
113115
s = interpolate(fmts, [11, 20]);
114-
// s is 'There are 11 objects. Remaining: 20'
116+
// s is "There are 11 objects. Remaining: 20"
115117
116118
.. seealso::
117119

docs/contributing/snippets/code-guide.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
License and copyright
33
---------------------
44

5-
When contributing code, you agree to put your changes and new code under the
6-
same license as the repository is already using, unless stated and agreed
7-
otherwise.
5+
When contributing project code, you agree to put your changes and new code
6+
under the repository license, :abbr:`GPL-3.0-or-later (GNU General Public
7+
License v3.0 or later)`, unless stated and agreed otherwise. New source files
8+
should follow the existing copyright and :abbr:`SPDX (Software Package Data
9+
Exchange)` license header style.
10+
11+
Use a different license only when there is a deliberate reason, such as files
12+
shared with repositories using more permissive licenses.
813

914
.. seealso::
1015

@@ -66,11 +71,14 @@ Type checking
6671
~~~~~~~~~~~~~
6772

6873
Any new code should utilize :pep:`484` type hints. We are using :program:`mypy`
69-
to check (because it has a Django plugin that makes type checking of Django
70-
apps doable).
74+
to check them because it has a Django plugin that makes type checking of Django
75+
apps practical.
7176

72-
The code base is not yet completely covered by type annotations, but some
73-
modules are already enforced for type checking in the CI.
77+
New and changed code should not introduce new :program:`mypy` failures where
78+
current Django typing support makes that practical. The code base is not yet
79+
completely covered by type annotations, and some Django constructs are
80+
difficult to annotate precisely. CI therefore enforces :program:`mypy` only for
81+
selected modules and reports other findings separately.
7482

7583
Coding standard and linting the code
7684
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -90,7 +98,7 @@ To check all files manually, run:
9098

9199
.. code-block:: sh
92100
93-
prek run --all-files
101+
uv run prek run --all-files
94102
95103
If you prefer the original :program:`pre-commit` client, it uses the same
96104
configuration from :file:`.pre-commit-config.yaml`.

docs/contributing/start.rst

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,30 @@ sources.
2727
git clone https://github.com/WeblateOrg/weblate.git
2828
cd weblate
2929
30-
2. Create a Python environment:
30+
2. Install Weblate and all dependencies useful for development:
3131

3232
.. code-block:: sh
3333
34-
uv venv .venv
35-
source .venv/bin/activate
36-
37-
3. Install Weblate (for this you need some system dependencies, see :doc:`../admin/install/source`) and all dependencies useful for development:
38-
39-
.. code-block:: sh
40-
41-
uv pip install -e '.[dev]'
34+
uv sync --all-extras --dev
4235
4336
3. Start a development server:
4437

4538
.. code-block:: sh
4639
47-
weblate runserver
40+
uv run weblate runserver
4841
4942
4. Depending on your configuration, you might also want to start Celery workers:
5043

5144
.. code-block:: sh
5245
53-
./weblate/examples/celery start
46+
uv run ./weblate/examples/celery start
5447
55-
5. To run a test (see :ref:`local-tests` for more details):
48+
5. To run tests (see :ref:`local-tests` for more details):
5649

5750
.. code-block:: sh
5851
5952
. scripts/test-database.sh
60-
pytest
53+
uv run pytest
6154
6255
.. seealso::
6356

@@ -143,15 +136,15 @@ to use:
143136

144137
.. image:: /images/pycharm-1.png
145138

146-
You can either choose to let PyCharm create the Python environment for you, or select an already
147-
existing one:
139+
Select the :file:`.venv` environment created by ``uv sync --all-extras --dev``
140+
to match the command-line development setup. You can also let PyCharm create a
141+
Python environment for you, but the uv-managed environment is preferred:
148142

149143
.. image:: /images/pycharm-2.png
150144

151-
Don't forget to install the dependencies once the interpreter is set:
152-
Either through the console (the console from the IDE will directly use your
153-
Python environment by default), or through the interface when you get a warning about missing
154-
dependencies.
145+
Don't forget to install the dependencies once the interpreter is set. When
146+
using the preferred uv-managed environment, run ``uv sync --all-extras --dev``
147+
from the console.
155148

156149
The second step is to set the right info to use Django natively inside PyCharm:
157150
The idea is to be able to immediately trigger the unit tests in the IDE.

docs/contributing/tests.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ The simple execution can look like:
5353
Local testing of Weblate
5454
+++++++++++++++++++++++++
5555

56-
Before running test, please ensure test dependencies are installed. This can be done by ``pip install -e .[test]``.
56+
Before running tests, please ensure development dependencies are installed:
57+
58+
.. code-block:: sh
59+
60+
uv sync --all-extras --dev
5761
5862
Testing using pytest
5963
~~~~~~~~~~~~~~~~~~~~
@@ -62,19 +66,19 @@ Prior to running tests you should collect static files as some tests rely on the
6266

6367
.. code-block:: sh
6468
65-
DJANGO_SETTINGS_MODULE=weblate.settings_test ./manage.py collectstatic
69+
DJANGO_SETTINGS_MODULE=weblate.settings_test uv run ./manage.py collectstatic --noinput
6670
67-
You can use `pytest` to run a testsuite locally:
71+
You can use `pytest` to run the test suite locally:
6872

6973
.. code-block:: sh
7074
71-
pytest weblate
75+
uv run pytest
7276
7377
Running an individual test file:
7478

7579
.. code-block:: sh
7680
77-
pytest weblate/utils/tests/test_search.py
81+
uv run pytest weblate/utils/tests/test_search.py
7882
7983
.. hint::
8084

@@ -108,17 +112,17 @@ The :file:`weblate/settings_test.py` is used in CI environment as well (see
108112
Local testing of Weblate modules
109113
--------------------------------
110114

111-
The tests are executed using :program:`py.test`. First you need to install test requirements:
115+
The tests are executed using :program:`pytest`. First you need to install development dependencies:
112116

113117
.. code-block:: sh
114118
115-
uv pip install -e '.[dev]'
119+
uv sync --all-extras --dev
116120
117121
You can then execute the testsuite in the repository checkout:
118122

119123
.. code-block:: sh
120124
121-
py.test
125+
uv run pytest
122126
123127
.. _test-data:
124128

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ ignore = [
295295
".gitmodules",
296296
".imgbotconfig",
297297
".reuse/dep5",
298-
".stylelintrc",
299298
".weblate",
300299
".well-known/*",
301300
".yamllint.yml",
@@ -592,13 +591,13 @@ ignore = [
592591
"DOC402", # CONFIG: `yield` is not documented in docstring
593592
"DOC501", # TODO: Raised exception missing from docstring
594593
"E203", # CONFIG: formatter
595-
"E501", # WONTFIX: we accept long strings (rest is formatted by black)
594+
"E501", # WONTFIX: we accept long strings (rest is formatted by Ruff)
596595
"FBT", # TODO: Boolean in function definition
597596
"FIX002", # CONFIG: we use TODO
598597
"PLR2004", # TODO: Magic value used in comparison, consider replacing 201 with a constant variable
599598
"PLR6301", # TODO: Method could be a function, class method, or static method
600599
"PLW2901", # TODO: overwriting variables inside loop
601-
"PT", # CONFIG: Not using pytest
600+
"PT", # CONFIG: pytest-style rules are not enforced
602601
"PTH", # TODO: Not using pathlib
603602
"RUF001", # WONTFIX: String contains ambiguous unicode character, we are using Unicode
604603
"TD002", # CONFIG: no detailed TODO documentation is required

0 commit comments

Comments
 (0)