From 094cbcf0541ad981764f62e368e4ab49d7540dee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Feb 2025 12:06:57 +0000 Subject: [PATCH 1/2] Bump ruff from 0.7.1 to 0.9.9 in /requirements Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.1 to 0.9.9. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.1...0.9.9) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements/dev.txt | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 8012ddc31897..1ebabe8d1304 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -303,25 +303,25 @@ tomli==2.2.1 \ --hash=sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272 \ --hash=sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a \ --hash=sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7 -ruff==0.7.1 \ - --hash=sha256:19aa200ec824c0f36d0c9114c8ec0087082021732979a359d6f3c390a6ff2a37 \ - --hash=sha256:27c1c52a8d199a257ff1e5582d078eab7145129aa02721815ca8fa4f9612dc35 \ - --hash=sha256:32f1e8a192e261366c702c5fb2ece9f68d26625f198a25c408861c16dc2dea9c \ - --hash=sha256:344cc2b0814047dc8c3a8ff2cd1f3d808bb23c6658db830d25147339d9bf9ea7 \ - --hash=sha256:4316bbf69d5a859cc937890c7ac7a6551252b6a01b1d2c97e8fc96e45a7c8b4a \ - --hash=sha256:56aad830af8a9db644e80098fe4984a948e2b6fc2e73891538f43bbe478461b8 \ - --hash=sha256:588a34e1ef2ea55b4ddfec26bbe76bc866e92523d8c6cdec5e8aceefeff02d99 \ - --hash=sha256:658304f02f68d3a83c998ad8bf91f9b4f53e93e5412b8f2388359d55869727fd \ - --hash=sha256:699085bf05819588551b11751eff33e9ca58b1b86a6843e1b082a7de40da1565 \ - --hash=sha256:79d3af9dca4c56043e738a4d6dd1e9444b6d6c10598ac52d146e331eb155a8ad \ - --hash=sha256:8422104078324ea250886954e48f1373a8fe7de59283d747c3a7eca050b4e378 \ - --hash=sha256:94fc32f9cdf72dc75c451e5f072758b118ab8100727168a3df58502b43a599ca \ - --hash=sha256:985818742b833bffa543a84d1cc11b5e6871de1b4e0ac3060a59a2bae3969250 \ - --hash=sha256:9d8a41d4aa2dad1575adb98a82870cf5db5f76b2938cf2206c22c940034a36f4 \ - --hash=sha256:b517a2011333eb7ce2d402652ecaa0ac1a30c114fbbd55c6b8ee466a7f600ee9 \ - --hash=sha256:c5c121b46abde94a505175524e51891f829414e093cd8326d6e741ecfc0a9112 \ - --hash=sha256:cb1bc5ed9403daa7da05475d615739cc0212e861b7306f314379d958592aaa89 \ - --hash=sha256:f38c41fcde1728736b4eb2b18850f6d1e3eedd9678c914dede554a70d5241307 +ruff==0.9.9 \ + --hash=sha256:0062ed13f22173e85f8f7056f9a24016e692efeea8704d1a5e8011b8aa850933 \ + --hash=sha256:0fadfe2c88724c9617339f62319ed40dcdadadf2888d5afb88bf3adee7b35bfb \ + --hash=sha256:18454e7fa4e4d72cffe28a37cf6a73cb2594f81ec9f4eca31a0aaa9ccdfb1590 \ + --hash=sha256:3403a53a32a90ce929aa2f758542aca9234befa133e29f4933dcef28a24317be \ + --hash=sha256:3aa0f6b75082c9be1ec5a1db78c6d4b02e2375c3068438241dc19c7c306cc61a \ + --hash=sha256:3ac78f127517209fe6d96ab00f3ba97cafe38718b23b1db3e96d8b2d39e37ddf \ + --hash=sha256:4efd7a96ed6d36ef011ae798bf794c5501a514be369296c672dab7921087fa57 \ + --hash=sha256:584cc66e89fb5f80f84b05133dd677a17cdd86901d6479712c96597a3f28e7fe \ + --hash=sha256:5ee162652869120ad260670706f3cd36cd3f32b0c651f02b6da142652c54941d \ + --hash=sha256:628abb5ea10345e53dff55b167595a159d3e174d6720bf19761f5e467e68d367 \ + --hash=sha256:6b4c376d929c25ecd6d87e182a230fa4377b8e5125a4ff52d506ee8c087153c1 \ + --hash=sha256:6df104d08c442a1aabcfd254279b8cc1e2cbf41a605aa3e26610ba1ec4acf0b0 \ + --hash=sha256:837982ea24091d4c1700ddb2f63b7070e5baec508e43b01de013dc7eff974ff1 \ + --hash=sha256:9494ba82a37a4b81b6a798076e4a3251c13243fc37967e998efe4cce58c8a8d1 \ + --hash=sha256:ab90a7944c5a1296f3ecb08d1cbf8c2da34c7e68114b1271a431a3ad30cb660e \ + --hash=sha256:abf3369325761a35aba75cd5c55ba1b5eb17d772f12ab168fbfac54be85cf18c \ + --hash=sha256:b6cd1428e834b35d7493354723543b28cc11dc14d1ce19b685f6e68e07c05ec7 \ + --hash=sha256:d7c62939daf5b2a15af48abbd23bea1efdd38c312d6e7c4cedf5a24e03207e17 typing_extensions==4.12.2 \ --hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \ --hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8 From 2255711fc3ab8992170eb5fd07104f3b63da55fd Mon Sep 17 00:00:00 2001 From: Andrew Williamson Date: Mon, 3 Mar 2025 16:29:15 +0000 Subject: [PATCH 2/2] ruff format rewrites --- scripts/install_deps.py | 4 +-- src/olympia/abuse/tests/test_models.py | 13 ++++--- src/olympia/accounts/tests/test_helpers.py | 3 +- src/olympia/accounts/tests/test_views.py | 4 +-- src/olympia/accounts/verify.py | 6 ++-- src/olympia/addons/fields.py | 4 +-- src/olympia/addons/models.py | 3 +- src/olympia/addons/tasks.py | 3 +- src/olympia/addons/tests/test_models.py | 12 +++---- src/olympia/addons/tests/test_tasks.py | 36 ++++++++++++------- src/olympia/addons/utils.py | 3 +- src/olympia/amo/management/__init__.py | 2 +- .../management/commands/compress_assets.py | 3 +- src/olympia/amo/management/commands/cron.py | 4 +-- src/olympia/amo/monitors.py | 3 +- src/olympia/amo/tests/__init__.py | 12 +++---- src/olympia/amo/tests/test_commands.py | 18 +++++----- src/olympia/amo/tests/test_helpers.py | 5 ++- src/olympia/amo/tests/test_views.py | 4 +-- src/olympia/amo/utils.py | 6 ++-- src/olympia/api/jwt_auth.py | 10 +++--- src/olympia/api/tests/test_authentication.py | 3 +- src/olympia/blocklist/mlbf.py | 4 +-- src/olympia/blocklist/tests/test_cron.py | 18 +++++----- src/olympia/blocklist/tests/test_mlbf.py | 3 +- src/olympia/devhub/forms.py | 7 ++-- src/olympia/devhub/tasks.py | 5 +-- src/olympia/devhub/tests/test_feeds.py | 4 +-- src/olympia/devhub/tests/test_forms.py | 7 ++-- src/olympia/devhub/tests/test_views.py | 9 +++-- src/olympia/devhub/tests/test_views_edit.py | 2 +- src/olympia/devhub/tests/test_views_submit.py | 30 ++++++++-------- src/olympia/discovery/models.py | 3 +- src/olympia/discovery/tests/test_commands.py | 5 +-- src/olympia/files/tests/test_utils.py | 7 ++-- src/olympia/hero/models.py | 3 +- .../lib/tests/test_jingo_minify_helpers.py | 5 ++- src/olympia/promoted/models.py | 10 ++---- src/olympia/ratings/tests/test_views.py | 2 +- src/olympia/reviewers/cron.py | 6 ++-- src/olympia/reviewers/tests/test_utils.py | 6 ++-- src/olympia/search/tests/test_filters.py | 6 ++-- .../search/tests/test_search_ranking.py | 23 ++++++------ src/olympia/shelves/tests/test_serializers.py | 2 +- src/olympia/signing/tests/test_views.py | 6 ++-- src/olympia/translations/tests/test_models.py | 9 +++-- src/olympia/users/models.py | 3 +- src/olympia/users/tests/test_models.py | 12 +++---- src/olympia/versions/tests/test_models.py | 7 ++-- src/olympia/versions/tests/test_views.py | 6 ++-- 50 files changed, 180 insertions(+), 191 deletions(-) diff --git a/scripts/install_deps.py b/scripts/install_deps.py index d6e9c6f5da0d..4baf117a5ea4 100755 --- a/scripts/install_deps.py +++ b/scripts/install_deps.py @@ -80,12 +80,12 @@ def main(targets): if pip_includes: # Install pip dependencies - print(f"Installing pip dependencies: {', '.join(pip_includes)} \n") + print(f'Installing pip dependencies: {", ".join(pip_includes)} \n') subprocess.run(pip_args, check=True) if npm_includes: # Install npm dependencies - print(f"Installing npm dependencies: {', '.join(npm_includes)} \n") + print(f'Installing npm dependencies: {", ".join(npm_includes)} \n') subprocess.run(npm_args, check=True) diff --git a/src/olympia/abuse/tests/test_models.py b/src/olympia/abuse/tests/test_models.py index 6df2dcf7dfdf..3f4bee77b6fb 100644 --- a/src/olympia/abuse/tests/test_models.py +++ b/src/olympia/abuse/tests/test_models.py @@ -1261,11 +1261,14 @@ def test_process_decision_for_legal_reviewed_job(self): assert AbuseReport.objects.filter(cinder_job=cinder_job).count() == 0 assert ContentDecision.objects.filter(appeal_job=cinder_job).count() == 0 - with mock.patch.object( - ContentActionDisableAddon, 'process_action' - ) as action_mock, mock.patch.object( - ContentActionDisableAddon, 'notify_owners' - ) as notify_mock: + with ( + mock.patch.object( + ContentActionDisableAddon, 'process_action' + ) as action_mock, + mock.patch.object( + ContentActionDisableAddon, 'notify_owners' + ) as notify_mock, + ): action_mock.return_value = None cinder_job.process_decision( decision_cinder_id='12345', diff --git a/src/olympia/accounts/tests/test_helpers.py b/src/olympia/accounts/tests/test_helpers.py index efb9997a6aae..1d7ee81806bf 100644 --- a/src/olympia/accounts/tests/test_helpers.py +++ b/src/olympia/accounts/tests/test_helpers.py @@ -6,8 +6,7 @@ def test_login_link(): request = RequestFactory().get('/en-US/firefox/addons') assert jinja_helpers.login_link({'request': request}) == ( - 'http://testserver/api/v5/accounts/login/start/' - '?to=%2Fen-US%2Ffirefox%2Faddons' + 'http://testserver/api/v5/accounts/login/start/?to=%2Fen-US%2Ffirefox%2Faddons' ) request = RequestFactory().get('/en-US/firefox/addons?blah=1') diff --git a/src/olympia/accounts/tests/test_views.py b/src/olympia/accounts/tests/test_views.py index 42c274b6cf2a..66523a214f23 100644 --- a/src/olympia/accounts/tests/test_views.py +++ b/src/olympia/accounts/tests/test_views.py @@ -2367,9 +2367,7 @@ def test_get_jwt_payload(self, decode_mock): def test_post(self): url = reverse_ns('fxa-notification', api_version='auth') - class_path = ( - f'{FxaNotificationView.__module__}.' f'{FxaNotificationView.__name__}' - ) + class_path = f'{FxaNotificationView.__module__}.{FxaNotificationView.__name__}' with ( mock.patch(f'{class_path}.get_jwt_payload') as get_jwt_mock, mock.patch(f'{class_path}.process_event') as process_event_mock, diff --git a/src/olympia/accounts/verify.py b/src/olympia/accounts/verify.py index 9e4b00eb9bf6..1039580fe896 100644 --- a/src/olympia/accounts/verify.py +++ b/src/olympia/accounts/verify.py @@ -44,9 +44,9 @@ def get_fxa_token(*, code=None, refresh_token=None, config=None): `id_token` keys. """ assert config, 'config dict must be provided to get_fxa_token' - assert ( - code or refresh_token - ), 'either code or refresh_token must be provided to get_fxa_token' + assert code or refresh_token, ( + 'either code or refresh_token must be provided to get_fxa_token' + ) log_identifier = f'code:{code}' if code else f'refresh:{refresh_token[:8]}' log.info(f'Getting token [{log_identifier}]') with statsd.timer('accounts.fxa.identify.token'): diff --git a/src/olympia/addons/fields.py b/src/olympia/addons/fields.py index be8f65f2c8a0..4365f5deaa65 100644 --- a/src/olympia/addons/fields.py +++ b/src/olympia/addons/fields.py @@ -59,9 +59,7 @@ def to_internal_value(self, data): ) if len(category_names) > 1 and 'other' in category_names: raise exceptions.ValidationError( - gettext( - 'The "other" category cannot be combined with another ' 'category' - ) + gettext('The "other" category cannot be combined with another category') ) categories = [] diff --git a/src/olympia/addons/models.py b/src/olympia/addons/models.py index f73f58119840..5da2e7e881b7 100644 --- a/src/olympia/addons/models.py +++ b/src/olympia/addons/models.py @@ -2210,8 +2210,7 @@ class Meta: constraints = [ models.UniqueConstraint( fields=('addon', 'user'), - name='addons_users_pending_confirmation_' - 'addon_id_user_id_38e3bb32_uniq', + name='addons_users_pending_confirmation_addon_id_user_id_38e3bb32_uniq', ), ] diff --git a/src/olympia/addons/tasks.py b/src/olympia/addons/tasks.py index 848b8fa58990..1d603de83817 100644 --- a/src/olympia/addons/tasks.py +++ b/src/olympia/addons/tasks.py @@ -231,8 +231,7 @@ def find_inconsistencies_between_es_and_db(ids, **kw): es_modified = result['_source']['modified'] if db_modified != es_modified: log.info( - 'Inconsistency found for addon %d: ' - 'modified is %s in db vs %s in es.', + 'Inconsistency found for addon %d: modified is %s in db vs %s in es.', pk, db_modified, es_modified, diff --git a/src/olympia/addons/tests/test_models.py b/src/olympia/addons/tests/test_models.py index d34b6f61d389..880ac45cf228 100644 --- a/src/olympia/addons/tests/test_models.py +++ b/src/olympia/addons/tests/test_models.py @@ -1207,12 +1207,12 @@ def test_review_replies(self): review_list = [rating.pk for rating in addon.ratings] - assert ( - new_rating.pk in review_list - ), 'Original review must show up in review list.' - assert ( - new_reply.pk not in review_list - ), 'Developer reply must not show up in review list.' + assert new_rating.pk in review_list, ( + 'Original review must show up in review list.' + ) + assert new_reply.pk not in review_list, ( + 'Developer reply must not show up in review list.' + ) def test_update_logs(self): addon = Addon.objects.get(id=3615) diff --git a/src/olympia/addons/tests/test_tasks.py b/src/olympia/addons/tests/test_tasks.py index 7f62927badec..9d63aad1d6a3 100644 --- a/src/olympia/addons/tests/test_tasks.py +++ b/src/olympia/addons/tests/test_tasks.py @@ -114,9 +114,12 @@ def test_create_missing_theme_previews(parse_addon_mock): # addon has all the complete previews already so skip when only_missing=True assert VersionPreview.objects.count() == 3 - with mock.patch( - f'{PATCH_PATH}.generate_static_theme_preview.apply_async' - ) as gen_preview, mock.patch(f'{PATCH_PATH}.resize_image') as resize: + with ( + mock.patch( + f'{PATCH_PATH}.generate_static_theme_preview.apply_async' + ) as gen_preview, + mock.patch(f'{PATCH_PATH}.resize_image') as resize, + ): recreate_theme_previews([theme.id], only_missing=True) assert gen_preview.call_count == 0 assert resize.call_count == 0 @@ -129,9 +132,12 @@ def test_create_missing_theme_previews(parse_addon_mock): firefox_preview.save() extra_preview.save() assert VersionPreview.objects.count() == 2 - with mock.patch( - f'{PATCH_PATH}.generate_static_theme_preview.apply_async' - ) as gen_preview, mock.patch(f'{PATCH_PATH}.resize_image') as resize: + with ( + mock.patch( + f'{PATCH_PATH}.generate_static_theme_preview.apply_async' + ) as gen_preview, + mock.patch(f'{PATCH_PATH}.resize_image') as resize, + ): recreate_theme_previews([theme.id], only_missing=True) assert gen_preview.call_count == 1 assert resize.call_count == 0 @@ -142,9 +148,12 @@ def test_create_missing_theme_previews(parse_addon_mock): firefox_preview.save() extra_preview.save() assert VersionPreview.objects.count() == 3 - with mock.patch( - f'{PATCH_PATH}.generate_static_theme_preview.apply_async' - ) as gen_preview, mock.patch(f'{PATCH_PATH}.resize_image') as resize: + with ( + mock.patch( + f'{PATCH_PATH}.generate_static_theme_preview.apply_async' + ) as gen_preview, + mock.patch(f'{PATCH_PATH}.resize_image') as resize, + ): recreate_theme_previews([theme.id], only_missing=True) assert gen_preview.call_count == 1 assert resize.call_count == 0 @@ -159,9 +168,12 @@ def test_create_missing_theme_previews(parse_addon_mock): assert firefox_preview.get_format('thumbnail') == 'gif' extra_preview.save() assert VersionPreview.objects.count() == 3 - with mock.patch( - f'{PATCH_PATH}.generate_static_theme_preview.apply_async' - ) as gen_preview, mock.patch(f'{PATCH_PATH}.resize_image') as resize: + with ( + mock.patch( + f'{PATCH_PATH}.generate_static_theme_preview.apply_async' + ) as gen_preview, + mock.patch(f'{PATCH_PATH}.resize_image') as resize, + ): recreate_theme_previews([theme.id], only_missing=True) assert gen_preview.call_count == 0 # not called assert resize.call_count == 2 diff --git a/src/olympia/addons/utils.py b/src/olympia/addons/utils.py index e98b825fb71b..79ac06763674 100644 --- a/src/olympia/addons/utils.py +++ b/src/olympia/addons/utils.py @@ -40,8 +40,7 @@ def _check(name): if violates_trademark: raise forms.ValidationError( gettext( - 'Add-on names cannot contain the Mozilla or ' - 'Firefox trademarks.' + 'Add-on names cannot contain the Mozilla or Firefox trademarks.' ) ) diff --git a/src/olympia/amo/management/__init__.py b/src/olympia/amo/management/__init__.py index d1a4328e6fe7..1dfceaa28ea0 100644 --- a/src/olympia/amo/management/__init__.py +++ b/src/olympia/amo/management/__init__.py @@ -206,7 +206,7 @@ def make_dir(self, name: str, force: bool = False) -> None: self.clean_dir(name) else: raise CommandError( - f'path {path} already exists.' 'Use --force to overwrite.' + f'path {path} already exists.Use --force to overwrite.' ) os.makedirs(path, exist_ok=True) diff --git a/src/olympia/amo/management/commands/compress_assets.py b/src/olympia/amo/management/commands/compress_assets.py index 180c32175d33..b12da242877d 100644 --- a/src/olympia/amo/management/commands/compress_assets.py +++ b/src/olympia/amo/management/commands/compress_assets.py @@ -48,8 +48,7 @@ def add_arguments(self, parser): '--dry-run', action='store_true', help=( - 'Do not actually compress assets, ' - 'just print the compressed file paths.' + 'Do not actually compress assets, just print the compressed file paths.' ), ) diff --git a/src/olympia/amo/management/commands/cron.py b/src/olympia/amo/management/commands/cron.py index 0c4a1569276e..a8e73138489d 100644 --- a/src/olympia/amo/management/commands/cron.py +++ b/src/olympia/amo/management/commands/cron.py @@ -42,9 +42,7 @@ def handle(self, *args, **options): path = settings.CRON_JOBS.get(name) if not path: - log.error( - 'Cron called with an unknown cron job: ' f'{name} {args} {kwargs}' - ) + log.error(f'Cron called with an unknown cron job: {name} {args} {kwargs}') raise CommandError(f'Unrecognized job name: {name}') module = import_module(path) diff --git a/src/olympia/amo/monitors.py b/src/olympia/amo/monitors.py index 4cf7eb0f8fd3..ac6b41679390 100644 --- a/src/olympia/amo/monitors.py +++ b/src/olympia/amo/monitors.py @@ -207,8 +207,7 @@ def signer(): ) if response.status_code != 200: status = ( - 'Failed to chat with signing service. ' - 'Invalid HTTP response code.' + 'Failed to chat with signing service. Invalid HTTP response code.' ) monitor_log.critical(status) signer_results = False diff --git a/src/olympia/amo/tests/__init__.py b/src/olympia/amo/tests/__init__.py index 63da70c4a22f..ea0c21e8d1f5 100644 --- a/src/olympia/amo/tests/__init__.py +++ b/src/olympia/amo/tests/__init__.py @@ -170,9 +170,9 @@ def check_links(expected, elements, selected=None): elm = elements.eq(idx) if text is not None: - assert ( - elm.text() == text - ), f'At index {idx}, expected {text}, got {elm.text()}' + assert elm.text() == text, ( + f'At index {idx}, expected {text}, got {elm.text()}' + ) if link is not None: # If we passed an
  • , try to find an . if not elm.filter('a'): @@ -507,9 +507,9 @@ def assertCloseToNow(self, dt, now=None): now = datetime.now() now_ts = time.mktime(now.timetuple()) - assert ( - dt_earlier_ts < now_ts < dt_later_ts - ), f'Expected datetime to be within a minute of {now}. Got {dt!r}.' + assert dt_earlier_ts < now_ts < dt_later_ts, ( + f'Expected datetime to be within a minute of {now}. Got {dt!r}.' + ) def assertQuerySetContentsEqual(self, qs1, qs2): """ diff --git a/src/olympia/amo/tests/test_commands.py b/src/olympia/amo/tests/test_commands.py index ff7368dea6a7..f9adfffa27e0 100644 --- a/src/olympia/amo/tests/test_commands.py +++ b/src/olympia/amo/tests/test_commands.py @@ -414,25 +414,25 @@ def test_backup_dir_path(self): expected_path = os.path.join(self.backup_dir, name) actual_path = self.base_data_command.backup_dir_path(name) - assert ( - actual_path == expected_path - ), f'Expected {expected_path}, got {actual_path}' + assert actual_path == expected_path, ( + f'Expected {expected_path}, got {actual_path}' + ) def test_backup_db_path(self): name = 'db_backup' expected_path = os.path.join(self.backup_dir, name, self.db_file) actual_path = self.base_data_command.backup_db_path(name) - assert ( - actual_path == expected_path - ), f'Expected {expected_path}, got {actual_path}' + assert actual_path == expected_path, ( + f'Expected {expected_path}, got {actual_path}' + ) def test_backup_storage_path(self): name = 'storage_backup' expected_path = os.path.join(self.backup_dir, name, self.storage_file) actual_path = self.base_data_command.backup_storage_path(name) - assert ( - actual_path == expected_path - ), f'Expected {expected_path}, got {actual_path}' + assert actual_path == expected_path, ( + f'Expected {expected_path}, got {actual_path}' + ) @mock.patch('olympia.amo.management.shutil.rmtree') @mock.patch('olympia.amo.management.logging') diff --git a/src/olympia/amo/tests/test_helpers.py b/src/olympia/amo/tests/test_helpers.py index f7eee9c46c1d..ccc8852cf75c 100644 --- a/src/olympia/amo/tests/test_helpers.py +++ b/src/olympia/amo/tests/test_helpers.py @@ -97,8 +97,7 @@ def test_template_escaping(): # Unless marked explicitly as safe expected = 'This is a

    test

    ' original = ( - '{{ _(\'{0}\')' - '|format_html("This is a

    test

    "|safe) }}' + '{{ _(\'{0}\')|format_html("This is a

    test

    "|safe) }}' ) assert render(original) == expected @@ -113,7 +112,7 @@ def test_template_escaping(): expected = '5 users' assert ( render( - "{{ ngettext('{0} user', '{0} users', 2)" '|format_html(5) }}' + "{{ ngettext('{0} user', '{0} users', 2)|format_html(5) }}" ) == expected ) diff --git a/src/olympia/amo/tests/test_views.py b/src/olympia/amo/tests/test_views.py index 7f8b54571f55..d7783de0ce1b 100644 --- a/src/olympia/amo/tests/test_views.py +++ b/src/olympia/amo/tests/test_views.py @@ -497,8 +497,8 @@ def test_disable_collections(self): @override_settings(ENGAGE_ROBOTS=True) def test_allow_mozilla_collections(self): """Make sure Mozilla collections are allowed""" - id_url = f"{reverse('collections.list')}{settings.TASK_USER_ID}/" - username_url = f"{reverse('collections.list')}mozilla/" + id_url = f'{reverse("collections.list")}{settings.TASK_USER_ID}/' + username_url = f'{reverse("collections.list")}mozilla/' response = self.client.get('/robots.txt') assert response.status_code == 200 content = response.content.decode('utf-8') diff --git a/src/olympia/amo/utils.py b/src/olympia/amo/utils.py index 3b92968580c9..085798858574 100644 --- a/src/olympia/amo/utils.py +++ b/src/olympia/amo/utils.py @@ -847,9 +847,9 @@ def __init__(self, *args, rel_location=None, **kwargs): if 'root_setting' in kwargs: self.root_setting = kwargs.pop('root_setting') self.rel_location = rel_location - assert not ( - rel_location is not None and kwargs.get('location') is not None - ), "Don't provide both location and rel_location" + assert not (rel_location is not None and kwargs.get('location') is not None), ( + "Don't provide both location and rel_location" + ) super().__init__(*args, **kwargs) def _clear_cached_properties(self, setting, **kwargs): diff --git a/src/olympia/api/jwt_auth.py b/src/olympia/api/jwt_auth.py index 748b37dfb836..aa82ab3adcd5 100644 --- a/src/olympia/api/jwt_auth.py +++ b/src/olympia/api/jwt_auth.py @@ -99,8 +99,9 @@ def jwt_decode_handler(token, get_api_key=APIKey.get_jwt_key): raise exceptions.AuthenticationFailed(detail=f'Invalid JWT: {exc}.') from exc except (jwt.exceptions.ImmatureSignatureError, jwt.InvalidIssuedAtError) as exc: log.info( - 'Invalid iat during JWT authentication: ' - '{e.__class__.__name__}: {e}'.format(e=exc) + 'Invalid iat during JWT authentication: {e.__class__.__name__}: {e}'.format( + e=exc + ) ) raise exceptions.AuthenticationFailed( detail='JWT iat (issued at time) is invalid. Make sure your ' @@ -115,8 +116,9 @@ def jwt_decode_handler(token, get_api_key=APIKey.get_jwt_key): if payload['exp'] - payload['iat'] > settings.MAX_APIKEY_JWT_AUTH_TOKEN_LIFETIME: log.info( - 'JWT auth: expiration is too long; ' - 'iss={iss}, iat={iat}, exp={exp}'.format(**payload) + 'JWT auth: expiration is too long; iss={iss}, iat={iat}, exp={exp}'.format( + **payload + ) ) raise exceptions.AuthenticationFailed( detail='JWT exp (expiration) is too long.' diff --git a/src/olympia/api/tests/test_authentication.py b/src/olympia/api/tests/test_authentication.py index 5c21dbea7e98..982005f5fe9d 100644 --- a/src/olympia/api/tests/test_authentication.py +++ b/src/olympia/api/tests/test_authentication.py @@ -256,8 +256,7 @@ def test_success(self): def test_authenticate_header(self): request = self.factory.post('/api/v4/whatever/') assert self.auth.authenticate_header(request) == ( - 'Session realm=' - '"Access to addons.mozilla.org internal API with session key"' + 'Session realm="Access to addons.mozilla.org internal API with session key"' ) def test_wrong_header_only_prefix(self): diff --git a/src/olympia/blocklist/mlbf.py b/src/olympia/blocklist/mlbf.py index 87b2c625734f..9792428d1ad8 100644 --- a/src/olympia/blocklist/mlbf.py +++ b/src/olympia/blocklist/mlbf.py @@ -67,7 +67,7 @@ def generate_mlbf(stats, include, exclude): stats['mlbf_bits'] = cascade.bitCount() log.info( - f'Filter cascade layers: {cascade.layerCount()}, ' f'bit: {cascade.bitCount()}' + f'Filter cascade layers: {cascade.layerCount()}, bit: {cascade.bitCount()}' ) cascade.verify(include=include, exclude=exclude) @@ -419,7 +419,7 @@ def validate(self): for dtype, count in data_types.items(): if count > 1: raise ValueError( - f'Item {item} found {count} times in data type ' f'{dtype.name}' + f'Item {item} found {count} times in data type {dtype.name}' ) @classmethod diff --git a/src/olympia/blocklist/tests/test_cron.py b/src/olympia/blocklist/tests/test_cron.py index a3558e0cfee3..4770be0157a4 100644 --- a/src/olympia/blocklist/tests/test_cron.py +++ b/src/olympia/blocklist/tests/test_cron.py @@ -328,19 +328,19 @@ def _test_upload_stash_and_filter( mlbf = MLBF.load_from_storage(self.current_time) if BlockListAction.UPLOAD_BLOCKED_FILTER.name in expected_actions: - assert mlbf.storage.exists( - mlbf.filter_path(BlockType.BLOCKED) - ), 'Expected filter {BlockType.BLOCKED} but none exists' + assert mlbf.storage.exists(mlbf.filter_path(BlockType.BLOCKED)), ( + 'Expected filter {BlockType.BLOCKED} but none exists' + ) if BlockListAction.UPLOAD_SOFT_BLOCKED_FILTER.name in expected_actions: - assert mlbf.storage.exists( - mlbf.filter_path(BlockType.SOFT_BLOCKED) - ), 'Expected filter {BlockType.SOFT_BLOCKED} but none exists' + assert mlbf.storage.exists(mlbf.filter_path(BlockType.SOFT_BLOCKED)), ( + 'Expected filter {BlockType.SOFT_BLOCKED} but none exists' + ) if BlockListAction.UPLOAD_STASH.name in expected_actions: - assert mlbf.storage.exists( - mlbf.stash_path - ), 'Expected stash but none exists' + assert mlbf.storage.exists(mlbf.stash_path), ( + 'Expected stash but none exists' + ) assert ( mock.call( diff --git a/src/olympia/blocklist/tests/test_mlbf.py b/src/olympia/blocklist/tests/test_mlbf.py index 188bc69f3449..201a9ac064c6 100644 --- a/src/olympia/blocklist/tests/test_mlbf.py +++ b/src/olympia/blocklist/tests/test_mlbf.py @@ -1157,8 +1157,7 @@ def test_validate_duplicate_item_in_single_data_type(self): mlbf.validate() assert ( - 'Item guid:version found 2 times in data type ' - f'{MLBFDataType.BLOCKED.name}' + f'Item guid:version found 2 times in data type {MLBFDataType.BLOCKED.name}' ) in str(e.exception) def test_validate_duplicate_item_in_multiple_data_types(self): diff --git a/src/olympia/devhub/forms.py b/src/olympia/devhub/forms.py index acf773b58ada..023c3e07169d 100644 --- a/src/olympia/devhub/forms.py +++ b/src/olympia/devhub/forms.py @@ -678,7 +678,7 @@ class PolicyForm(TranslationFormMixin, AMOModelForm): eula = TransField( widget=TransTextarea(), required=False, - label=_("Please specify your add-on's " 'End-User License Agreement:'), + label=_("Please specify your add-on's End-User License Agreement:"), ) has_priv = forms.BooleanField( required=False, label=_('This add-on has a Privacy Policy'), label_suffix='' @@ -721,8 +721,9 @@ class WithSourceMixin: def get_invalid_source_file_type_message(self): valid_extensions_string = '(%s)' % ', '.join(VALID_SOURCE_EXTENSIONS) return gettext( - 'Unsupported file type, please upload an archive ' - 'file {extensions}.'.format(extensions=valid_extensions_string) + 'Unsupported file type, please upload an archive file {extensions}.'.format( + extensions=valid_extensions_string + ) ) def clean_source(self): diff --git a/src/olympia/devhub/tasks.py b/src/olympia/devhub/tasks.py index d5af161dbdd9..7bc6d0605af4 100644 --- a/src/olympia/devhub/tasks.py +++ b/src/olympia/devhub/tasks.py @@ -92,8 +92,9 @@ def submit_file(*, addon_pk, upload_pk, client_info): ) else: log.info( - 'Skipping version creation for {upload_uuid} that failed ' - 'validation'.format(upload_uuid=upload.uuid) + 'Skipping version creation for {upload_uuid} that failed validation'.format( + upload_uuid=upload.uuid + ) ) diff --git a/src/olympia/devhub/tests/test_feeds.py b/src/olympia/devhub/tests/test_feeds.py index bc32743f86f4..13a62c49aad8 100644 --- a/src/olympia/devhub/tests/test_feeds.py +++ b/src/olympia/devhub/tests/test_feeds.py @@ -227,7 +227,7 @@ def test_logged_out(self): assert response.status_code == 302 def test_xss_addon(self): - self.addon.name = "' + self.addon.name = "" self.addon.save() self.log_creates(1) doc = self.get_pq() @@ -236,7 +236,7 @@ def test_xss_addon(self): assert '<script>' in str(doc), 'XSS FTL' def test_xss_unlisted_addon(self): - self.addon.name = "' + self.addon.name = "" self.addon.save() self.make_addon_unlisted(self.addon) self.log_creates(1) diff --git a/src/olympia/devhub/tests/test_forms.py b/src/olympia/devhub/tests/test_forms.py index 3469cefd189b..f9ec474d7d9b 100644 --- a/src/olympia/devhub/tests/test_forms.py +++ b/src/olympia/devhub/tests/test_forms.py @@ -564,9 +564,10 @@ def test_preview_transparency(self): form.save(addon) preview = addon.previews.all()[0] assert os.path.exists(preview.thumbnail_path) - with storage.open(preview.thumbnail_path, 'rb') as thumb_file, open( - get_image_path(name + '.jpg'), 'rb' - ) as sample_file: + with ( + storage.open(preview.thumbnail_path, 'rb') as thumb_file, + open(get_image_path(name + '.jpg'), 'rb') as sample_file, + ): assert thumb_file.read() == sample_file.read() @mock.patch('olympia.amo.utils.pngcrush_image') diff --git a/src/olympia/devhub/tests/test_views.py b/src/olympia/devhub/tests/test_views.py index c80601115350..78368bae8b42 100644 --- a/src/olympia/devhub/tests/test_views.py +++ b/src/olympia/devhub/tests/test_views.py @@ -186,9 +186,9 @@ def test_public_addon(self): assert item.find('p.downloads'), 'Expected weekly downloads' assert item.find('p.users'), 'Expected ADU' assert item.find('.item-details'), 'Expected item details' - assert not item.find( - 'p.incomplete' - ), 'Unexpected message about incomplete add-on' + assert not item.find('p.incomplete'), ( + 'Unexpected message about incomplete add-on' + ) appver = self.addon.current_version.apps.all()[0] appver.delete() @@ -1314,8 +1314,7 @@ def test_fileupload_validation_not_a_xpi_file(self): msg = validation['messages'][0] assert msg['type'] == 'error' assert msg['message'] == ( - 'Unsupported file type, please upload a supported file ' - '(.crx, .xpi, .zip).' + 'Unsupported file type, please upload a supported file (.crx, .xpi, .zip).' ) assert not msg['description'] diff --git a/src/olympia/devhub/tests/test_views_edit.py b/src/olympia/devhub/tests/test_views_edit.py index 853d816cffec..b017e01941b2 100644 --- a/src/olympia/devhub/tests/test_views_edit.py +++ b/src/olympia/devhub/tests/test_views_edit.py @@ -353,7 +353,7 @@ def test_edit_xss(self): Let's try to put xss in our description, and safe html, and verify that we are playing safe. """ - self.addon.description = 'This\n**IS**' "" + self.addon.description = "This\n**IS**" self.addon.save() response = self.client.get(self.url) assert response.status_code == 200 diff --git a/src/olympia/devhub/tests/test_views_submit.py b/src/olympia/devhub/tests/test_views_submit.py index 312783299be1..e8a7e135328c 100644 --- a/src/olympia/devhub/tests/test_views_submit.py +++ b/src/olympia/devhub/tests/test_views_submit.py @@ -628,9 +628,9 @@ def test_success_listed(self): response, reverse('devhub.submit.source', args=[addon.slug, 'listed']) ) log_items = ActivityLog.objects.for_addons(addon) - assert log_items.filter( - action=amo.LOG.CREATE_ADDON.id - ), 'New add-on creation never logged.' + assert log_items.filter(action=amo.LOG.CREATE_ADDON.id), ( + 'New add-on creation never logged.' + ) self.statsd_incr_mock.assert_any_call('devhub.submission.addon.listed') provenance = VersionProvenance.objects.get() assert provenance.version == version @@ -648,9 +648,9 @@ def test_success_custom_user_agent(self): response, reverse('devhub.submit.source', args=[addon.slug, 'listed']) ) log_items = ActivityLog.objects.for_addons(addon) - assert log_items.filter( - action=amo.LOG.CREATE_ADDON.id - ), 'New add-on creation never logged.' + assert log_items.filter(action=amo.LOG.CREATE_ADDON.id), ( + 'New add-on creation never logged.' + ) self.statsd_incr_mock.assert_any_call('devhub.submission.addon.listed') provenance = VersionProvenance.objects.get() assert provenance.version == version @@ -1573,9 +1573,9 @@ def test_submit_success_required(self): # Test add-on log activity. log_items = ActivityLog.objects.for_addons(addon) - assert not log_items.filter( - action=amo.LOG.EDIT_PROPERTIES.id - ), "Setting properties on submit needn't be logged." + assert not log_items.filter(action=amo.LOG.EDIT_PROPERTIES.id), ( + "Setting properties on submit needn't be logged." + ) @override_switch('content-optimization', active=False) def test_submit_success_optional_fields(self): @@ -1628,9 +1628,9 @@ def test_submit_success_required_with_content_optimization(self): # Test add-on log activity. log_items = ActivityLog.objects.for_addons(addon) - assert not log_items.filter( - action=amo.LOG.EDIT_PROPERTIES.id - ), "Setting properties on submit needn't be logged." + assert not log_items.filter(action=amo.LOG.EDIT_PROPERTIES.id), ( + "Setting properties on submit needn't be logged." + ) @override_switch('content-optimization', active=True) def test_submit_success_optional_fields_with_content_optimization(self): @@ -1866,9 +1866,9 @@ def test_submit_success_required(self): # Test add-on log activity. log_items = ActivityLog.objects.for_addons(addon) - assert not log_items.filter( - action=amo.LOG.EDIT_PROPERTIES.id - ), "Setting properties on submit needn't be logged." + assert not log_items.filter(action=amo.LOG.EDIT_PROPERTIES.id), ( + "Setting properties on submit needn't be logged." + ) def test_submit_success_optional_fields(self): # Set/change the optional fields too diff --git a/src/olympia/discovery/models.py b/src/olympia/discovery/models.py index ed952fe2061e..eb0371dd9820 100644 --- a/src/olympia/discovery/models.py +++ b/src/olympia/discovery/models.py @@ -36,8 +36,7 @@ class DiscoveryItem(OnChangeMixin, ModelBase): default=0, blank=True, db_index=True, - help_text='Position in the discovery pane in China ' - '(See position field above).', + help_text='Position in the discovery pane in China (See position field above).', ) position_override = models.PositiveSmallIntegerField( default=0, diff --git a/src/olympia/discovery/tests/test_commands.py b/src/olympia/discovery/tests/test_commands.py index 295a54af99c0..d3725994d2d7 100644 --- a/src/olympia/discovery/tests/test_commands.py +++ b/src/olympia/discovery/tests/test_commands.py @@ -138,8 +138,9 @@ def test_basic(self): body=json.dumps(shelves_fake_data), ) - with tempfile.NamedTemporaryFile() as file_, override_settings( - EDITORIAL_CONTENT_FILENAME=file_.name + with ( + tempfile.NamedTemporaryFile() as file_, + override_settings(EDITORIAL_CONTENT_FILENAME=file_.name), ): call_command('extract_content_strings') diff --git a/src/olympia/files/tests/test_utils.py b/src/olympia/files/tests/test_utils.py index 1a158884f994..501547a25d53 100644 --- a/src/olympia/files/tests/test_utils.py +++ b/src/olympia/files/tests/test_utils.py @@ -75,9 +75,10 @@ def test_not_dict(self): def test_parse_xpi_no_manifest(self): fake_zip = utils.make_xpi({'dummy': 'dummy'}) - with mock.patch( - 'olympia.files.utils.get_file' - ) as get_file_mock, self.assertRaises(utils.NoManifestFound) as exc: + with ( + mock.patch('olympia.files.utils.get_file') as get_file_mock, + self.assertRaises(utils.NoManifestFound) as exc, + ): get_file_mock.return_value = fake_zip utils.parse_xpi(None) assert isinstance(exc.exception, forms.ValidationError) diff --git a/src/olympia/hero/models.py b/src/olympia/hero/models.py index d930f5758d3b..d251f3a87043 100644 --- a/src/olympia/hero/models.py +++ b/src/olympia/hero/models.py @@ -204,8 +204,7 @@ def clean(self): if self.is_external and not self.promoted_addon.addon.homepage: error_dict['is_external'] = ValidationError( - 'External primary shelves need a homepage defined in ' - 'addon details.' + 'External primary shelves need a homepage defined in addon details.' ) elif not self.is_external: can_add_to_primary = ( diff --git a/src/olympia/lib/tests/test_jingo_minify_helpers.py b/src/olympia/lib/tests/test_jingo_minify_helpers.py index 94783957184f..f5b822ca6fae 100644 --- a/src/olympia/lib/tests/test_jingo_minify_helpers.py +++ b/src/olympia/lib/tests/test_jingo_minify_helpers.py @@ -92,9 +92,8 @@ def test_css_helper(): template = from_string('{{ css("common", debug=False) }}') rendered = template.render() - expected = ( - '' % (settings.STATIC_URL,) + expected = '' % ( + settings.STATIC_URL, ) assert rendered == expected diff --git a/src/olympia/promoted/models.py b/src/olympia/promoted/models.py index 783cee50b323..93e55503f936 100644 --- a/src/olympia/promoted/models.py +++ b/src/olympia/promoted/models.py @@ -304,9 +304,7 @@ class Meta: ] def __str__(self): - return ( - f'{self.get_group_id_display()} - ' f'{self.version.addon}: {self.version}' - ) + return f'{self.get_group_id_display()} - {self.version.addon}: {self.version}' @property def application(self): @@ -342,11 +340,7 @@ class Meta: ] def __str__(self): - return ( - f'{self.promoted_group.name} - ' - f'{self.version} - ' - f'{self.application.short}' - ) + return f'{self.promoted_group.name} - {self.version} - {self.application.short}' @property def application(self): diff --git a/src/olympia/ratings/tests/test_views.py b/src/olympia/ratings/tests/test_views.py index 764c0e7a6fb2..663177576587 100644 --- a/src/olympia/ratings/tests/test_views.py +++ b/src/olympia/ratings/tests/test_views.py @@ -2217,7 +2217,7 @@ def test_post_twice_same_version(self): ) assert response.status_code == 400 assert response.data['non_field_errors'] == [ - "You can't leave more than one review for the same version of " 'an add-on.' + "You can't leave more than one review for the same version of an add-on." ] @override_settings(CACHES=locmem_cache) diff --git a/src/olympia/reviewers/cron.py b/src/olympia/reviewers/cron.py index 0c7181927800..a1958cfa0869 100644 --- a/src/olympia/reviewers/cron.py +++ b/src/olympia/reviewers/cron.py @@ -21,9 +21,9 @@ def record_reviewer_queues_counts(): for group in PROMOTED_GROUPS: if group.id != PROMOTED_GROUP_CHOICES.NOT_PROMOTED: querysets[f'{PendingManualApprovalQueueTable.name}/{group.api_name}'] = ( - PendingManualApprovalQueueTable.get_queryset( - None - ).filter(promotedaddon__group_id=group.id) + PendingManualApprovalQueueTable.get_queryset(None).filter( + promotedaddon__group_id=group.id + ) ) # Execute a count for each queryset and record a QueueCount instance for it diff --git a/src/olympia/reviewers/tests/test_utils.py b/src/olympia/reviewers/tests/test_utils.py index 3051fef4f66f..e15ca82c1d67 100644 --- a/src/olympia/reviewers/tests/test_utils.py +++ b/src/olympia/reviewers/tests/test_utils.py @@ -1955,9 +1955,9 @@ def test_confirm_auto_approved_approves_for_promoted(self): self.addon.reload() self.addon.promotedaddon.reload() - assert ( - self.addon.promoted_group().id == PROMOTED_GROUP_CHOICES.NOTABLE - ), self.addon.promotedaddon + assert self.addon.promoted_group().id == PROMOTED_GROUP_CHOICES.NOTABLE, ( + self.addon.promotedaddon + ) assert self.review_version.reload().approved_for_groups == [ (PROMOTED_GROUPS_BY_ID.get(PROMOTED_GROUP_CHOICES.NOTABLE), amo.FIREFOX), (PROMOTED_GROUPS_BY_ID.get(PROMOTED_GROUP_CHOICES.NOTABLE), amo.ANDROID), diff --git a/src/olympia/search/tests/test_filters.py b/src/olympia/search/tests/test_filters.py index 45cd9d21a433..6987cb02775b 100644 --- a/src/olympia/search/tests/test_filters.py +++ b/src/olympia/search/tests/test_filters.py @@ -72,8 +72,7 @@ def _test_q(self, qs, query): assert should[1] == { 'multi_match': { - '_name': 'MultiMatch(name_l10n_en-us,name_l10n_en-ca,' - 'name_l10n_en-gb)', + '_name': 'MultiMatch(name_l10n_en-us,name_l10n_en-ca,name_l10n_en-gb)', 'analyzer': 'english', 'boost': 5.0, 'fields': ['name_l10n_en-us', 'name_l10n_en-ca', 'name_l10n_en-gb'], @@ -1229,8 +1228,7 @@ def test_combined(self): should = bool_['must'][0]['function_score']['query']['bool']['should'] expected = { 'multi_match': { - '_name': 'MultiMatch(name_l10n_en-us,name_l10n_en-ca,' - 'name_l10n_en-gb)', + '_name': 'MultiMatch(name_l10n_en-us,name_l10n_en-ca,name_l10n_en-gb)', 'analyzer': 'english', 'boost': 5.0, 'fields': ['name_l10n_en-us', 'name_l10n_en-ca', 'name_l10n_en-gb'], diff --git a/src/olympia/search/tests/test_search_ranking.py b/src/olympia/search/tests/test_search_ranking.py index 7cc53541e747..80f957c5c61b 100644 --- a/src/olympia/search/tests/test_search_ranking.py +++ b/src/olympia/search/tests/test_search_ranking.py @@ -35,13 +35,13 @@ def get_name_from_result(item, expected_lang): if expected_lang is None: expected_lang = params['lang'] - assert len(results) == len( - expected - ), 'Expected {} results but {} found for query "{}": {}'.format( - len(expected), - len(results), - query, - [x['name'][expected_lang] for x in results], + assert len(results) == len(expected), ( + 'Expected {} results but {} found for query "{}": {}'.format( + len(expected), + len(results), + query, + [x['name'][expected_lang] for x in results], + ) ) assert data['count'] == len(results) @@ -189,8 +189,7 @@ def setUpTestData(cls): name='Privacy Badger', slug='privacy-badger17', summary=( - 'Protects your privacy by blocking spying ads and invisible ' - 'trackers.' + 'Protects your privacy by blocking spying ads and invisible trackers.' ), weekly_downloads=22931, ) @@ -211,8 +210,7 @@ def setUpTestData(cls): name='Privacy Settings', slug='privacy-settings', summary=( - "Alter Firefox's built-in privacy settings easily with a " - 'toolbar panel.' + "Alter Firefox's built-in privacy settings easily with a toolbar panel." ), weekly_downloads=1492, ) @@ -241,8 +239,7 @@ def setUpTestData(cls): name='Ghostery', slug='ghostery', summary=( - 'See who’s tracking you online and protect your privacy with ' - 'Ghostery.' + 'See who’s tracking you online and protect your privacy with Ghostery.' ), weekly_downloads=49315, ) diff --git a/src/olympia/shelves/tests/test_serializers.py b/src/olympia/shelves/tests/test_serializers.py index 2e2da824be30..018b1127237b 100644 --- a/src/olympia/shelves/tests/test_serializers.py +++ b/src/olympia/shelves/tests/test_serializers.py @@ -165,7 +165,7 @@ def _get_result_url(self, instance, tag=None): elif instance.endpoint == 'random-tag': return ( f'{reverse_ns("addon-search")}{criteria}' - f'{"&" if len(criteria)>1 else ""}tag={tag}' + f'{"&" if len(criteria) > 1 else ""}tag={tag}' ) else: return None diff --git a/src/olympia/signing/tests/test_views.py b/src/olympia/signing/tests/test_views.py index 442d9bab2dfd..9fec42eef8a3 100644 --- a/src/olympia/signing/tests/test_views.py +++ b/src/olympia/signing/tests/test_views.py @@ -369,8 +369,7 @@ def test_mozilla_signed_allowed(self): 'PUT', guid=guid, version='0.0.1', - filename='src/olympia/files/fixtures/files/' - 'webextension_signed_already.xpi', + filename='src/olympia/files/fixtures/files/webextension_signed_already.xpi', ) assert response.status_code == 201 assert qs.exists() @@ -390,8 +389,7 @@ def test_mozilla_signed_not_allowed(self): 'PUT', guid=guid, version='0.0.1', - filename='src/olympia/files/fixtures/files/' - 'webextension_signed_already.xpi', + filename='src/olympia/files/fixtures/files/webextension_signed_already.xpi', ) assert response.status_code == 400 assert response.data['error'] == ( diff --git a/src/olympia/translations/tests/test_models.py b/src/olympia/translations/tests/test_models.py index 17274372dae6..8c968e657b38 100644 --- a/src/olympia/translations/tests/test_models.py +++ b/src/olympia/translations/tests/test_models.py @@ -81,9 +81,9 @@ def test_translation_sequence_increases(self): newtrans1.save() newtrans2 = Translation.new('def', 'de') newtrans2.save() - assert ( - newtrans2.pk > newtrans1.pk - ), 'Translation sequence needs to keep increasing.' + assert newtrans2.pk > newtrans1.pk, ( + 'Translation sequence needs to keep increasing.' + ) class TranslationTestCase(TestCase): @@ -731,8 +731,7 @@ def test_mixed_markdown_html(self): s = '__bold text__ or _italics_not bold' x = PurifiedMarkdownTranslation(localized_string=s) assert x.__html__() == ( - 'bold text or italics' - '<b>not bold</b>' + 'bold text or italics<b>not bold</b>' ) def test_html(self): diff --git a/src/olympia/users/models.py b/src/olympia/users/models.py index 8fe9ea68b070..9a17d2c1855a 100644 --- a/src/olympia/users/models.py +++ b/src/olympia/users/models.py @@ -450,8 +450,7 @@ def has_read_developer_agreement(self): return self.read_dev_agreement > change_config_date except (ValueError, TypeError): log.exception( - 'last_developer_agreement_change misconfigured, ' - '"%s" is not a datetime', + 'last_developer_agreement_change misconfigured, "%s" is not a datetime', last_agreement_change_config, ) return self.read_dev_agreement > settings.DEV_AGREEMENT_CHANGE_FALLBACK diff --git a/src/olympia/users/tests/test_models.py b/src/olympia/users/tests/test_models.py index 566a44b2c321..1ebe0efa28b5 100644 --- a/src/olympia/users/tests/test_models.py +++ b/src/olympia/users/tests/test_models.py @@ -762,12 +762,12 @@ def test_review_replies(self): review_list = [rating.pk for rating in user.ratings] assert len(review_list) == 1 - assert ( - new_rating.pk in review_list - ), 'Original review must show up in ratings list.' - assert ( - new_reply.pk not in review_list - ), 'Developer reply must not show up in ratings list.' + assert new_rating.pk in review_list, ( + 'Original review must show up in ratings list.' + ) + assert new_reply.pk not in review_list, ( + 'Developer reply must not show up in ratings list.' + ) def test_num_addons_listed(self): """Test that num_addons_listed is only considering add-ons for which diff --git a/src/olympia/versions/tests/test_models.py b/src/olympia/versions/tests/test_models.py index 8d9f36b2eaba..26d844b04e5b 100644 --- a/src/olympia/versions/tests/test_models.py +++ b/src/olympia/versions/tests/test_models.py @@ -2125,9 +2125,10 @@ def test_track_upload_time(self): self.upload.update(created=datetime.now() - timedelta(days=1)) mock_path = 'olympia.versions.models.statsd.' - with mock.patch(f'{mock_path}timing') as mock_timing, mock.patch( - f'{mock_path}incr' - ) as mock_incr: + with ( + mock.patch(f'{mock_path}timing') as mock_timing, + mock.patch(f'{mock_path}incr') as mock_incr, + ): Version.from_upload( self.upload, self.addon, diff --git a/src/olympia/versions/tests/test_views.py b/src/olympia/versions/tests/test_views.py index 0434cace6206..0426dfc3f5b7 100644 --- a/src/olympia/versions/tests/test_views.py +++ b/src/olympia/versions/tests/test_views.py @@ -101,9 +101,9 @@ def test_version_update_info(self): response = self.client.get(self.url) assert response.status_code == 200 assert response['Content-Type'] == 'application/xhtml+xml' - assert ( - b'
    ' in response.content - ), 'Should be using XHTML self-closing tags!' + assert b'
    ' in response.content, ( + 'Should be using XHTML self-closing tags!' + ) doc = PyQuery(response.content, parser='html') assert doc('html').attr('xmlns') == 'http://www.w3.org/1999/xhtml' assert doc('p').html() == (