Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ruff from 0.7.1 to 0.9.9 in /requirements #23126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
13 changes: 8 additions & 5 deletions src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions src/olympia/accounts/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 1 addition & 3 deletions src/olympia/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/olympia/accounts/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
4 changes: 1 addition & 3 deletions src/olympia/addons/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
3 changes: 1 addition & 2 deletions src/olympia/addons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
]

Expand Down
3 changes: 1 addition & 2 deletions src/olympia/addons/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/olympia/addons/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 24 additions & 12 deletions src/olympia/addons/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/olympia/addons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/olympia/amo/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/olympia/amo/management/commands/compress_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
),
)

Expand Down
4 changes: 1 addition & 3 deletions src/olympia/amo/management/commands/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/olympia/amo/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/olympia/amo/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <li>, try to find an <a>.
if not elm.filter('a'):
Expand Down Expand Up @@ -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):
"""
Expand Down
18 changes: 9 additions & 9 deletions src/olympia/amo/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 2 additions & 3 deletions src/olympia/amo/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def test_template_escaping():
# Unless marked explicitly as safe
expected = '<a href="...">This is a <h1>test</h1></a>'
original = (
'{{ _(\'<a href="...">{0}</a>\')'
'|format_html("This is a <h1>test</h1>"|safe) }}'
'{{ _(\'<a href="...">{0}</a>\')|format_html("This is a <h1>test</h1>"|safe) }}'
)
assert render(original) == expected

Expand All @@ -113,7 +112,7 @@ def test_template_escaping():
expected = '<b>5 users</b>'
assert (
render(
"{{ ngettext('<b>{0} user</b>', '<b>{0} users</b>', 2)" '|format_html(5) }}'
"{{ ngettext('<b>{0} user</b>', '<b>{0} users</b>', 2)|format_html(5) }}"
)
== expected
)
Expand Down
4 changes: 2 additions & 2 deletions src/olympia/amo/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions src/olympia/amo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading
Loading