зеркало из https://github.com/mozilla/pontoon.git
Replace black, flake8, pyupgrade with ruff for Python linting and formatting (#3248)
This commit is contained in:
Родитель
a19ec1fb0f
Коммит
d650739031
15
.flake8
15
.flake8
|
@ -1,15 +0,0 @@
|
|||
[flake8]
|
||||
max_line_length = 88
|
||||
ignore = E203, E501, W503
|
||||
|
||||
exclude =
|
||||
media/*,
|
||||
*/pontoon-intro/*,
|
||||
docs/conf.py,
|
||||
*/migrations/*,
|
||||
docs/conf.py,
|
||||
setup.py,
|
||||
node_modules,
|
||||
bin,
|
||||
tag-admin,
|
||||
translate
|
|
@ -18,7 +18,7 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
flake8:
|
||||
ruff:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
@ -29,33 +29,7 @@ jobs:
|
|||
run: |
|
||||
pip install -U pip
|
||||
pip install -r requirements/lint.txt
|
||||
- name: flake8
|
||||
run: flake8 pontoon
|
||||
|
||||
black:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
pip install -U pip
|
||||
pip install -r requirements/lint.txt
|
||||
- name: black
|
||||
run: black --check pontoon
|
||||
|
||||
pyupgrade:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
pip install -U pip
|
||||
pip install -r requirements/lint.txt
|
||||
- name: pyupgrade
|
||||
run: pyupgrade --py311-plus *.py `find pontoon -name \*.py`
|
||||
- name: ruff lint
|
||||
run: ruff check pontoon
|
||||
- name: ruff format
|
||||
run: ruff format --check pontoon
|
||||
|
|
|
@ -115,33 +115,22 @@ To run the required linters on the Python and the Javascript code at once you ca
|
|||
Python code conventions
|
||||
=======================
|
||||
|
||||
Our Python code is automatically formatted using `black <https://black.readthedocs.io/en/stable/>`_.
|
||||
Our Python code is automatically formatted using `ruff <https://docs.astral.sh/ruff/>`_.
|
||||
We enforce that in our Continuous Integration, so you will need to run
|
||||
black on your code before sending it for review.
|
||||
ruff on your code before sending it for review.
|
||||
|
||||
You can run black locally either as an
|
||||
`add-on in your code editor <https://black.readthedocs.io/en/stable/editor_integration.html>`_,
|
||||
or as a `git pre-hook commit <https://black.readthedocs.io/en/stable/version_control_integration.html>`_.
|
||||
You can run ruff locally either as an
|
||||
`add-on in your code editor <https://docs.astral.sh/ruff/integrations/#vs-code-official>`_,
|
||||
or as a `git pre-hook commit <https://docs.astral.sh/ruff/integrations/#pre-commit>`_.
|
||||
Alternatively, you can format your code using:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ make black
|
||||
$ make ruff
|
||||
|
||||
We also require Python code to use newer syntax of Python. You can upgrade automatically by running:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ make pyupgrade
|
||||
|
||||
Additionally, we use a linter to verify that imports are correct. You can run it with:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
$ make flake8
|
||||
|
||||
In the rare case when you cannot fix a flake8 error, use ``# noqa`` to make the linter
|
||||
ignore that error. Note that in most cases, it is better to fix the issues than ignoring them.
|
||||
In the rare case when you cannot fix an error, use ``# noqa`` to make the linter
|
||||
ignore that error (see `documentation <https://docs.astral.sh/ruff/linter/#error-suppression>`_).
|
||||
Note that in most cases, it is better to fix the issues than ignoring them.
|
||||
|
||||
|
||||
Javascript code conventions
|
||||
|
|
32
Makefile
32
Makefile
|
@ -9,7 +9,7 @@ SITE_URL ?= http://localhost:8000
|
|||
USER_ID?=1000
|
||||
GROUP_ID?=1000
|
||||
|
||||
.PHONY: build build-translate build-tagadmin build-server server-env setup run clean shell ci test test-translate test-tagadmin test-server jest pytest format lint types eslint prettier check-prettier flake8 pyupgrade check-pyupgrade black check-black dropdb dumpdb loaddb sync-projects requirements
|
||||
.PHONY: build build-translate build-tagadmin build-server server-env setup run clean shell ci test test-translate test-tagadmin test-server jest pytest format lint types eslint prettier check-prettier ruff check-ruff dropdb dumpdb loaddb sync-projects requirements
|
||||
|
||||
help:
|
||||
@echo "Welcome to Pontoon!\n"
|
||||
|
@ -34,12 +34,9 @@ help:
|
|||
@echo " eslint Runs a code linter on the JavaScript code"
|
||||
@echo " prettier Runs the Prettier formatter"
|
||||
@echo " check-prettier Runs a check for format issues with the Prettier formatter"
|
||||
@echo " flake8 Runs the flake8 style guides on all Python code"
|
||||
@echo " pyupgrade Upgrades all Python code to newer syntax of Python"
|
||||
@echo " check-pyupgrade Runs a check for outdated syntax of Python with the pyupgrade formatter"
|
||||
@echo " black Runs the black formatter on all Python code"
|
||||
@echo " check-black Runs a check for format issues with the black formatter"
|
||||
@echo " dropdb Completely remove the postgres container and its data"
|
||||
@echo " ruff Runs the ruff formatter on all Python code"
|
||||
@echo " check-ruff Runs a check for format issues with the ruff formatter"
|
||||
@echo " dumpdb Create a postgres database dump with timestamp used as file name"
|
||||
@echo " loaddb Load a database dump into postgres, file name in DB_DUMP_FILE"
|
||||
@echo " sync-projects Runs the synchronization task on all projects"
|
||||
|
@ -99,9 +96,9 @@ test-server: pytest
|
|||
pytest:
|
||||
"${DC}" run ${run_opts} --rm server pytest --cov-report=xml:pontoon/coverage.xml --cov=. $(opts)
|
||||
|
||||
format: prettier pyupgrade black
|
||||
format: prettier ruff
|
||||
|
||||
lint: types eslint check-prettier flake8 check-pyupgrade check-black
|
||||
lint: types eslint check-prettier check-ruff
|
||||
|
||||
types:
|
||||
npm run types -w translate
|
||||
|
@ -115,20 +112,13 @@ prettier:
|
|||
check-prettier:
|
||||
npm run check-prettier
|
||||
|
||||
flake8:
|
||||
"${DC}" run --rm server flake8 pontoon/
|
||||
ruff:
|
||||
"${DC}" run --rm server ruff check --fix pontoon/
|
||||
"${DC}" run --rm server ruff format pontoon/
|
||||
|
||||
pyupgrade:
|
||||
"${DC}" run --rm server pyupgrade --exit-zero-even-if-changed --py311-plus *.py `find pontoon -name \*.py`
|
||||
|
||||
check-pyupgrade:
|
||||
"${DC}" run --rm server pyupgrade --py311-plus *.py `find pontoon -name \*.py`
|
||||
|
||||
black:
|
||||
"${DC}" run --rm server black pontoon/
|
||||
|
||||
check-black:
|
||||
"${DC}" run --rm server black --check pontoon
|
||||
check-ruff:
|
||||
"${DC}" run --rm server ruff check pontoon
|
||||
"${DC}" run --rm server ruff format --check pontoon
|
||||
|
||||
dropdb:
|
||||
"${DC}" down --volumes postgresql
|
||||
|
|
|
@ -5,7 +5,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -6,7 +6,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("actionlog", "0001_squashed_0002_auto_20200123_1843"),
|
||||
]
|
||||
|
|
|
@ -37,7 +37,6 @@ def delete_action_logs_for_pretranslations(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("actionlog", "0002_auto_20200703_0709"),
|
||||
]
|
||||
|
|
|
@ -3,6 +3,7 @@ Pontoon requires a very specific subset of functionality implemented in django a
|
|||
Because of concerns related to the security concerns it's a better to keep only selected
|
||||
views and don't allow user to tamper with the state of an account.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
from django.urls import path
|
||||
|
|
|
@ -80,8 +80,8 @@ class Command(BaseCommand):
|
|||
path = reverse("pontoon.insights")
|
||||
url = urljoin(SITE_URL, path)
|
||||
keys = [
|
||||
f"/pontoon.insights.views/team_pretranslation_quality",
|
||||
f"/pontoon.insights.views/project_pretranslation_quality",
|
||||
"/pontoon.insights.views/team_pretranslation_quality",
|
||||
"/pontoon.insights.views/project_pretranslation_quality",
|
||||
]
|
||||
self.warmup_url(url, keys=keys)
|
||||
self.stdout.write("Insights page warmed up.")
|
||||
|
|
|
@ -12,7 +12,6 @@ import pontoon.base.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -1437,7 +1437,6 @@ def squashed_run_python(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0001_squashed_0154_auto_20200206_1736"),
|
||||
("guardian", "__first__"),
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0002_auto_20200322_1821"),
|
||||
]
|
||||
|
|
|
@ -11,7 +11,6 @@ def make_projects_public(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0003_add_visibility_field_to_project"),
|
||||
]
|
||||
|
|
|
@ -177,7 +177,6 @@ def remove_terminology_project(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0004_make_old_projects_public_again"),
|
||||
("terminology", "0002_term_entity"),
|
||||
|
|
|
@ -6,7 +6,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0005_add_terminology_project"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0006_auto_20200703_0710"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0007_machinery_sources_translation"),
|
||||
]
|
||||
|
|
|
@ -29,7 +29,6 @@ def revert_system_user_email(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0009_change_pontoon_users_emails"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0010_comment_pinned"),
|
||||
]
|
||||
|
|
|
@ -6,7 +6,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0011_rename_download_prefix"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0012_auto_20201020_1830"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0013_transvision_remove"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0014_auto_20210310_1945"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0015_userprofile_has_dismissed_addon_promotion"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0016_entity_key_required"),
|
||||
]
|
||||
|
|
|
@ -39,7 +39,6 @@ def remove_entity_context(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0017_entity_context"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import pontoon.base.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0018_populate_entity_context"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0019_alter_locale_cldr_plurals"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import pontoon.base.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0020_notification_subscriptions"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0021_alter_repository_url"),
|
||||
]
|
||||
|
|
|
@ -28,7 +28,6 @@ def fuzzy_to_missing(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0022_reviewed_suggestions"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("base", "0023_fuzzy_to_missing"),
|
||||
|
|
|
@ -9,7 +9,6 @@ def remove_tm_entries_of_rejected(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0024_fuzzy_to_pretranslated_strings"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0025_remove_tm_entries_of_rejected"),
|
||||
]
|
||||
|
|
|
@ -14,7 +14,6 @@ def propagate_pretranslation_enabled(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0026_projectlocale_pretranslation_enabled"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0027_keep_pretranslation_enabled"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0028_userprofile_new_contributor_notifications"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0029_external_accounts"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0030_userprofile_username"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0031_userprofile_bio"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0032_user_profile_visibility"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0033_userprofile_contact_email"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0034_rename_matrix_to_chat"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0035_ratio_to_rate"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0036_locale_google_automl_model"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0037_alter_locale_population"),
|
||||
]
|
||||
|
|
|
@ -24,7 +24,6 @@ def revert_mark_system_users(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Generated by Django 3.2.15 on 2023-02-23 16:02
|
||||
from django.db import migrations
|
||||
from pontoon.base.models import Project, Resource, Entity, ChangedEntityLocale
|
||||
from pontoon.base.models import Project, ChangedEntityLocale
|
||||
|
||||
|
||||
def remove_changed_entity_locale_entries_for_repository_projects(apps, schema_editor):
|
||||
|
@ -10,7 +10,6 @@ def remove_changed_entity_locale_entries_for_repository_projects(apps, schema_ed
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0040_remove_changed_entity_locale_entries_for_repository_projects"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0041_alter_userprofile_visibility_email"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0042_locale_accesskey_localization"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0043_alter_locale_accesskey_localization"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0044_delete_subpage"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0045_drop_project_links_url_width"),
|
||||
]
|
||||
|
|
|
@ -13,7 +13,6 @@ def fix_lt_plural_rule(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0046_projectslughistory"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0047_fix_lt_plural_rule"),
|
||||
]
|
||||
|
|
|
@ -10,7 +10,6 @@ def fix_gettext_plural_forms(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0048_userprofile_theme"),
|
||||
]
|
||||
|
|
|
@ -31,7 +31,6 @@ def unescape_strings_xml_apostrophes(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0049_fix_pluralform_data"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import django.db.models.deletion
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0050_strings_xml_apostrophes"),
|
||||
]
|
||||
|
|
|
@ -11,7 +11,6 @@ def rename_logged_in_users(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0051_localecodehistory"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("base", "0052_rename_logged_in_users"),
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0053_alter_translation_index_together"),
|
||||
]
|
||||
|
|
|
@ -25,7 +25,6 @@ def reset_resource_order(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0054_resource_order"),
|
||||
]
|
||||
|
|
|
@ -12,7 +12,6 @@ def remove_unused_tm_entries(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0055_populate_resource_order"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0056_remove_fuzzy_and_non-approved_tm_entries"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0057_remove_lang_format"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0058_remove_tr_tr_collation"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0059_alter_translation_machinery_sources"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
(
|
||||
"base",
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0061_userprofile_email_communications_enabled"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import uuid
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0062_userprofile_email_consent_dismissed_at"),
|
||||
]
|
||||
|
|
|
@ -13,7 +13,6 @@ def populate_unique_id(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0063_userprofile_unique_id"),
|
||||
]
|
||||
|
|
|
@ -109,7 +109,9 @@ class TranslationMemoryEntryQuerySet(models.QuerySet):
|
|||
matches_pks.append(pk)
|
||||
quality_sql_map.append(When(pk=pk, then=Value(quality * 100)))
|
||||
|
||||
entries = self.filter(pk__in=matches_pks,).annotate(
|
||||
entries = self.filter(
|
||||
pk__in=matches_pks,
|
||||
).annotate(
|
||||
quality=Case(
|
||||
*quality_sql_map,
|
||||
**dict(
|
||||
|
|
|
@ -131,9 +131,10 @@ def test_repo_url_for_path_no_match(repo_git, locale_a, settings):
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_repo_pull(repo_git):
|
||||
with patch("pontoon.sync.repositories.update_from_vcs") as m_update_from_vcs, patch(
|
||||
"pontoon.sync.repositories.get_revision"
|
||||
) as m_get_revision:
|
||||
with (
|
||||
patch("pontoon.sync.repositories.update_from_vcs") as m_update_from_vcs,
|
||||
patch("pontoon.sync.repositories.get_revision") as m_get_revision,
|
||||
):
|
||||
repo_git.url = "https://example.com"
|
||||
m_get_revision.return_value = "asdf"
|
||||
assert repo_git.pull() == {"single_locale": "asdf"}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Test consistency of calculations between `calculate_stats` and `translation.save()`.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from pontoon.base.models import TranslatedResource
|
||||
from pontoon.checks.models import (
|
||||
|
|
|
@ -9,9 +9,10 @@ from pontoon.base.views import AjaxFormView, AjaxFormPostView
|
|||
|
||||
|
||||
def test_view_ajax_form(rf):
|
||||
with patch("pontoon.base.views.AjaxFormView.get_form") as form_m, patch(
|
||||
"pontoon.base.views.AjaxFormView.render_to_response"
|
||||
) as response_m:
|
||||
with (
|
||||
patch("pontoon.base.views.AjaxFormView.get_form") as form_m,
|
||||
patch("pontoon.base.views.AjaxFormView.render_to_response") as response_m,
|
||||
):
|
||||
form_m.return_value = 7
|
||||
response_m.return_value = 23
|
||||
|
||||
|
@ -28,8 +29,9 @@ def test_view_ajax_form(rf):
|
|||
|
||||
|
||||
def test_view_ajax_form_post(rf):
|
||||
with patch("pontoon.base.views.AjaxFormPostView.get_form") as form_m, patch(
|
||||
"pontoon.base.views.AjaxFormPostView.render_to_response"
|
||||
with (
|
||||
patch("pontoon.base.views.AjaxFormPostView.get_form") as form_m,
|
||||
patch("pontoon.base.views.AjaxFormPostView.render_to_response"),
|
||||
):
|
||||
with pytest.raises(Http404):
|
||||
AjaxFormPostView.as_view()(rf.get("/foo/bar"))
|
||||
|
@ -41,9 +43,10 @@ def test_view_ajax_form_post(rf):
|
|||
|
||||
|
||||
def test_view_ajax_form_submit_bad(rf):
|
||||
with patch("pontoon.base.views.AjaxFormView.get_form") as form_m, patch(
|
||||
"pontoon.base.views.AjaxFormView.render_to_response"
|
||||
) as response_m:
|
||||
with (
|
||||
patch("pontoon.base.views.AjaxFormView.get_form") as form_m,
|
||||
patch("pontoon.base.views.AjaxFormView.render_to_response") as response_m,
|
||||
):
|
||||
_form = MagicMock()
|
||||
_form.is_valid.return_value = False
|
||||
type(_form).errors = PropertyMock(return_value=["BAD", "STUFF"])
|
||||
|
@ -68,8 +71,9 @@ def test_view_ajax_form_submit_bad(rf):
|
|||
|
||||
|
||||
def test_view_ajax_form_submit_success(rf):
|
||||
with patch("pontoon.base.views.AjaxFormView.get_form") as form_m, patch(
|
||||
"pontoon.base.views.AjaxFormView.render_to_response"
|
||||
with (
|
||||
patch("pontoon.base.views.AjaxFormView.get_form") as form_m,
|
||||
patch("pontoon.base.views.AjaxFormView.render_to_response"),
|
||||
):
|
||||
_form = MagicMock()
|
||||
_form.is_valid.return_value = True
|
||||
|
|
|
@ -470,7 +470,7 @@ def sanitize_xml_input_string(string):
|
|||
"""
|
||||
|
||||
illegal_xml_chars_re = re.compile(
|
||||
"[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]"
|
||||
"[\x00-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]"
|
||||
)
|
||||
|
||||
return illegal_xml_chars_re.sub("", string)
|
||||
|
|
|
@ -58,50 +58,41 @@ def test_empty_translations(get_entity_mock):
|
|||
== {}
|
||||
)
|
||||
|
||||
assert (
|
||||
run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
assert run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
{ $var ->
|
||||
[a] { "" }
|
||||
*[b] { "" }
|
||||
}
|
||||
.attr = { "" }
|
||||
""",
|
||||
)
|
||||
== {"pndbWarnings": ["Empty translation"]}
|
||||
)
|
||||
) == {"pndbWarnings": ["Empty translation"]}
|
||||
|
||||
assert (
|
||||
run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
assert run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
{ $var ->
|
||||
[a] { "x" }
|
||||
*[b] { "y" }
|
||||
}
|
||||
.attr = { "" }
|
||||
""",
|
||||
)
|
||||
== {"pndbWarnings": ["Empty translation"]}
|
||||
)
|
||||
) == {"pndbWarnings": ["Empty translation"]}
|
||||
|
||||
assert (
|
||||
run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
assert run_checks(
|
||||
get_entity_mock("ftl", string="key =\n .attr = value"),
|
||||
"",
|
||||
"""key =
|
||||
{ $var ->
|
||||
[a] { "x" }
|
||||
*[b] { "" }
|
||||
}
|
||||
.attr = { "y" }
|
||||
""",
|
||||
)
|
||||
== {"pndbWarnings": ["Empty translation"]}
|
||||
)
|
||||
) == {"pndbWarnings": ["Empty translation"]}
|
||||
|
||||
assert (
|
||||
run_checks(
|
||||
|
|
|
@ -5,6 +5,7 @@ actively maintained and current codebase is broken between various versions of D
|
|||
Because of that I decided to implement our migrations with intent to drop it when django develops
|
||||
its own solution.
|
||||
"""
|
||||
|
||||
import copy
|
||||
|
||||
from django.db.migrations.operations.base import Operation
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Collation lookups allow a user to set text-collation to search queries.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from pontoon.db import IContainsCollate # noqa
|
||||
|
|
|
@ -28,7 +28,6 @@ def remove_homepage_entry(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("homepage", "0001_squashed_0002_add_homepage_content"),
|
||||
]
|
||||
|
|
|
@ -7,7 +7,6 @@ import pontoon.insights.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
|
|
|
@ -6,7 +6,6 @@ import django.utils.timezone
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0012_auto_20201020_1830"),
|
||||
("insights", "0001_initial"),
|
||||
|
|
|
@ -6,7 +6,6 @@ import pontoon.insights.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0002_project_projectlocale"),
|
||||
]
|
||||
|
|
|
@ -98,7 +98,6 @@ UPDATE insights_projectinsightssnapshot SET new_source_strings = 0;
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0003_project_insights"),
|
||||
]
|
||||
|
|
|
@ -6,7 +6,6 @@ import pontoon.insights.models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0004_project_insights_data"),
|
||||
]
|
||||
|
|
|
@ -100,7 +100,6 @@ UPDATE insights_projectlocaleinsightssnapshot SET new_source_strings = 0;
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0005_projectlocale_insights"),
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0006_projectlocale_insights_data"),
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Generated by Django 3.2.4 on 2021-11-30 19:56
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
from django.db import migrations
|
||||
from django.db.models import F
|
||||
|
||||
|
@ -68,7 +68,6 @@ def reset_time_to_review_suggestions(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0007_time_to_review_suggestions"),
|
||||
]
|
||||
|
|
|
@ -100,7 +100,6 @@ UPDATE insights_projectlocaleinsightssnapshot SET new_source_strings = 0;
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0008_time_to_review_suggestions_data"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0024_fuzzy_to_pretranslated_strings"),
|
||||
("insights", "0009_fix_projectlocale_insights_data"),
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0010_fuzzy_to_pretranslated_strings"),
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Generated by Django 3.2.4 on 2021-11-30 19:56
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
from django.db import migrations
|
||||
from django.db.models import F
|
||||
|
||||
|
@ -73,7 +73,6 @@ def reset_time_to_review_pretranslations(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0011_time_to_review_pretranslations"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0012_time_to_review_pretranslations_data"),
|
||||
]
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import statistics
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from django.db import migrations
|
||||
from django.db.models import F
|
||||
from sacrebleu.metrics import CHRF
|
||||
|
@ -177,7 +176,6 @@ def reset_pretranslation_quality(apps, schema_editor):
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0013_pretranslation_quality"),
|
||||
]
|
||||
|
|
|
@ -100,7 +100,6 @@ UPDATE insights_projectlocaleinsightssnapshot SET new_source_strings = 0;
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("insights", "0014_pretranslation_quality_data"),
|
||||
]
|
||||
|
|
|
@ -60,7 +60,8 @@ def get_time_to_review_12_month_avg(category, query_filters=None):
|
|||
.values(
|
||||
"month",
|
||||
f"time_to_review_{category}_avg",
|
||||
).order_by("month")
|
||||
)
|
||||
.order_by("month")
|
||||
)
|
||||
|
||||
times_to_review = [x[f"time_to_review_{category}_avg"] for x in insights]
|
||||
|
|
|
@ -7,14 +7,14 @@ from pontoon.base.models import User
|
|||
def test_dismiss_email_consent(member):
|
||||
"""Test if dismiss_email_consent view works and fails as expected."""
|
||||
params = {}
|
||||
response = member.client.post(f"/dismiss-email-consent/", params)
|
||||
response = member.client.post("/dismiss-email-consent/", params)
|
||||
assert response.status_code == 400
|
||||
assert response.json()["message"] == "Bad Request: Value not set"
|
||||
|
||||
params = {
|
||||
"value": "false",
|
||||
}
|
||||
response = member.client.post(f"/dismiss-email-consent/", params)
|
||||
response = member.client.post("/dismiss-email-consent/", params)
|
||||
profile = User.objects.get(pk=member.user.pk).profile
|
||||
assert profile.email_communications_enabled is False
|
||||
assert profile.email_consent_dismissed_at is not None
|
||||
|
@ -24,7 +24,7 @@ def test_dismiss_email_consent(member):
|
|||
params = {
|
||||
"value": "true",
|
||||
}
|
||||
response = member.client.post(f"/dismiss-email-consent/", params)
|
||||
response = member.client.post("/dismiss-email-consent/", params)
|
||||
profile = User.objects.get(pk=member.user.pk).profile
|
||||
assert profile.email_communications_enabled is True
|
||||
assert profile.email_consent_dismissed_at is not None
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Django settings for Pontoon."""
|
||||
|
||||
import re
|
||||
import os
|
||||
import socket
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче