Replace black, flake8, pyupgrade with ruff for Python linting and formatting (#3248)

This commit is contained in:
Francesco Lodolo 2024-06-03 19:08:47 +02:00 коммит произвёл GitHub
Родитель a19ec1fb0f
Коммит d650739031
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
127 изменённых файлов: 176 добавлений и 333 удалений

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

36
.github/workflows/py-lint.yml поставляемый
Просмотреть файл

@ -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

Просмотреть файл

@ -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

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше