mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-15 23:33:19 +00:00
ruff: enable B (flake8-bugbear)
Fixes 71 violations across production and test code: - B904 (~50): raise-from in except blocks; from None at API/view boundaries, from exc where the cause is the direct origin - B017 (9): pytest.raises(Exception) → specific type or match= arg - B007 (5): unused loop vars renamed to _ - B027 (1): missing @abstractmethod on DateParserPluginBase.__exit__ - B028 (3): warnings.warn without stacklevel=2 in test utils - B011 (1): assert False → raise AssertionError() - B905 (3): zip() without strict=False - B009 (3): getattr with constant string (auto-fixed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6f1673e0ae
commit
976eb3beaa
@@ -353,9 +353,10 @@ class MailMocker(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
len(expected_call_args),
|
||||
)
|
||||
|
||||
for (mock_args, mock_kwargs), expected_signatures in zip(
|
||||
for (_, mock_kwargs), expected_signatures in zip(
|
||||
self._queue_consumption_tasks_mock.call_args_list,
|
||||
expected_call_args,
|
||||
strict=False,
|
||||
):
|
||||
consume_tasks = mock_kwargs["consume_tasks"]
|
||||
|
||||
@@ -365,6 +366,7 @@ class MailMocker(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
for consume_task, expected_signature in zip(
|
||||
consume_tasks,
|
||||
expected_signatures,
|
||||
strict=False,
|
||||
):
|
||||
input_doc = consume_task.kwargs["input_doc"]
|
||||
overrides = consume_task.kwargs["overrides"]
|
||||
@@ -387,7 +389,7 @@ class MailMocker(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
||||
"""
|
||||
Applies pending actions to mails by inspecting calls to the queue_consumption_tasks method.
|
||||
"""
|
||||
for args, kwargs in self._queue_consumption_tasks_mock.call_args_list:
|
||||
for _, kwargs in self._queue_consumption_tasks_mock.call_args_list:
|
||||
message = kwargs["message"]
|
||||
rule = kwargs["rule"]
|
||||
apply_mail_action([], rule.pk, message.uid, message.subject, message.date)
|
||||
|
||||
@@ -184,7 +184,12 @@ class TestMailMessageGpgDecryptor(TestMail):
|
||||
EMAIL_GNUPG_HOME=empty_gpg_home,
|
||||
):
|
||||
message_decryptor = MailMessageDecryptor()
|
||||
self.assertRaises(Exception, message_decryptor.run, encrypted_message)
|
||||
self.assertRaisesRegex(
|
||||
Exception,
|
||||
"Decryption failed",
|
||||
message_decryptor.run,
|
||||
encrypted_message,
|
||||
)
|
||||
finally:
|
||||
# Clean up the temporary GPG home used only by this test
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user