mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-27 21:23:20 +00:00
Chore: enable refurb (FURB) ruff rules
FURB is part of ruff 0.16's expanded default rule set and is almost entirely autofixable.
This commit is contained in:
@@ -192,6 +192,7 @@ extend-select = [
|
||||
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
|
||||
"FBT", # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
|
||||
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
|
||||
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
|
||||
"G201", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
|
||||
"I", # https://docs.astral.sh/ruff/rules/#isort-i
|
||||
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
|
||||
|
||||
@@ -216,7 +216,7 @@ class ConsumerPluginMixin:
|
||||
current_progress,
|
||||
max_progress,
|
||||
document_id=document_id,
|
||||
owner_id=self.metadata.owner_id if self.metadata.owner_id else None,
|
||||
owner_id=self.metadata.owner_id or None,
|
||||
users_can_view=(self.metadata.view_users or [])
|
||||
+ (self.metadata.change_users or []),
|
||||
groups_can_view=(self.metadata.view_groups or [])
|
||||
@@ -674,9 +674,7 @@ class ConsumerPlugin(
|
||||
document=document,
|
||||
logging_group=self.logging_group,
|
||||
classifier=classifier,
|
||||
original_file=self.unmodified_original
|
||||
if self.unmodified_original
|
||||
else self.working_copy,
|
||||
original_file=self.unmodified_original or self.working_copy,
|
||||
)
|
||||
|
||||
# After everything is in the database, copy the files into
|
||||
|
||||
@@ -41,7 +41,7 @@ def get_default_file_extension(mime_type: str) -> str:
|
||||
return supported[mime_type]
|
||||
|
||||
ext = mimetypes.guess_extension(mime_type)
|
||||
return ext if ext else ""
|
||||
return ext or ""
|
||||
|
||||
|
||||
def is_file_ext_supported(ext: str) -> bool:
|
||||
|
||||
@@ -1333,7 +1333,7 @@ class PreConsumeTestCase(DirectoriesMixin, GetConsumerMixin, TestCase):
|
||||
script_calls = [
|
||||
call
|
||||
for call in m.call_args_list
|
||||
if call.args and call.args[0] and call.args[0][0] not in ("pdftotext",)
|
||||
if call.args and call.args[0] and call.args[0][0] != "pdftotext"
|
||||
]
|
||||
self.assertEqual(script_calls, [])
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def build_workflow_action_context(
|
||||
else None
|
||||
)
|
||||
|
||||
filename = document.original_file if document.original_file else ""
|
||||
filename = document.original_file or ""
|
||||
return {
|
||||
"title": overrides.title
|
||||
if overrides and overrides.title
|
||||
|
||||
@@ -241,7 +241,7 @@ def check_v3_minimum_upgrade_version(
|
||||
return []
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
last_applied = sorted(applied)[-1] if applied else "(none)"
|
||||
last_applied = max(applied) if applied else "(none)"
|
||||
logger.error(
|
||||
"V3 upgrade check failed: last applied documents migration is %r. "
|
||||
"Expected '1075_workflowaction_order' (v2.20.15). "
|
||||
|
||||
@@ -76,7 +76,7 @@ class RemoteEngineConfig:
|
||||
def engine_is_valid(self) -> bool:
|
||||
"""Return True when the engine is known and fully configured."""
|
||||
return (
|
||||
self.engine in ("azureai",)
|
||||
self.engine == "azureai"
|
||||
and self.api_key is not None
|
||||
and not (self.engine == "azureai" and self.endpoint is None)
|
||||
)
|
||||
|
||||
@@ -111,7 +111,7 @@ def parse_dict_from_str(
|
||||
return False
|
||||
|
||||
settings: dict[str, Any] = copy.deepcopy(defaults) if defaults else {}
|
||||
_type_map = type_map if type_map else {}
|
||||
_type_map = type_map or {}
|
||||
|
||||
if not env_str:
|
||||
return settings
|
||||
|
||||
Reference in New Issue
Block a user