mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Configures ruff as the one stop linter and resolves warnings it raised
This commit is contained in:
@@ -42,7 +42,7 @@ def path_check(var, directory):
|
||||
Error(
|
||||
writeable_message.format(var),
|
||||
writeable_hint.format(
|
||||
f"\n{dir_mode} {dir_owner} {dir_group} " f"{directory}\n",
|
||||
f"\n{dir_mode} {dir_owner} {dir_group} {directory}\n",
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -158,7 +158,7 @@ def settings_values_check(app_configs, **kwargs):
|
||||
try:
|
||||
import zoneinfo
|
||||
except ImportError: # pragma: nocover
|
||||
import backports.zoneinfo as zoneinfo
|
||||
from backports import zoneinfo
|
||||
msgs = []
|
||||
if settings.TIME_ZONE not in zoneinfo.available_timezones():
|
||||
msgs.append(
|
||||
|
@@ -12,13 +12,13 @@ class StatusConsumer(WebsocketConsumer):
|
||||
|
||||
def connect(self):
|
||||
if not self._authenticated():
|
||||
raise DenyConnection()
|
||||
raise DenyConnection
|
||||
else:
|
||||
async_to_sync(self.channel_layer.group_add)(
|
||||
"status_updates",
|
||||
self.channel_name,
|
||||
)
|
||||
raise AcceptConnection()
|
||||
raise AcceptConnection
|
||||
|
||||
def disconnect(self, close_code):
|
||||
async_to_sync(self.channel_layer.group_discard)(
|
||||
|
@@ -65,9 +65,11 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
if "user_permissions" in validated_data:
|
||||
user_permissions = validated_data.pop("user_permissions")
|
||||
password = None
|
||||
if "password" in validated_data:
|
||||
if len(validated_data.get("password").replace("*", "")) > 0:
|
||||
password = validated_data.pop("password")
|
||||
if (
|
||||
"password" in validated_data
|
||||
and len(validated_data.get("password").replace("*", "")) > 0
|
||||
):
|
||||
password = validated_data.pop("password")
|
||||
user = User.objects.create(**validated_data)
|
||||
# set groups
|
||||
if groups:
|
||||
|
@@ -282,7 +282,8 @@ INSTALLED_APPS = [
|
||||
"django_filters",
|
||||
"django_celery_results",
|
||||
"guardian",
|
||||
] + env_apps
|
||||
*env_apps,
|
||||
]
|
||||
|
||||
if DEBUG:
|
||||
INSTALLED_APPS.append("channels")
|
||||
@@ -398,10 +399,7 @@ if ENABLE_HTTP_REMOTE_USER:
|
||||
)
|
||||
|
||||
# X-Frame options for embedded PDF display:
|
||||
if DEBUG:
|
||||
X_FRAME_OPTIONS = "ANY"
|
||||
else:
|
||||
X_FRAME_OPTIONS = "SAMEORIGIN"
|
||||
X_FRAME_OPTIONS = "ANY" if DEBUG else "SAMEORIGIN"
|
||||
|
||||
|
||||
# The next 3 settings can also be set using just PAPERLESS_URL
|
||||
@@ -424,7 +422,7 @@ if _paperless_url:
|
||||
_paperless_uri = urlparse(_paperless_url)
|
||||
CSRF_TRUSTED_ORIGINS.append(_paperless_url)
|
||||
CORS_ALLOWED_ORIGINS.append(_paperless_url)
|
||||
if ALLOWED_HOSTS != ["*"]:
|
||||
if ["*"] != ALLOWED_HOSTS:
|
||||
ALLOWED_HOSTS.append(_paperless_uri.hostname)
|
||||
else:
|
||||
# always allow localhost. Necessary e.g. for healthcheck in docker.
|
||||
|
@@ -15,18 +15,18 @@ def handle_failed_login(sender, credentials, request, **kwargs):
|
||||
if client_ip is None:
|
||||
logger.info(
|
||||
f"Login failed for user `{credentials['username']}`."
|
||||
+ " Unable to determine IP address.",
|
||||
" Unable to determine IP address.",
|
||||
)
|
||||
else:
|
||||
if is_routable:
|
||||
# We got the client's IP address
|
||||
logger.info(
|
||||
f"Login failed for user `{credentials['username']}`"
|
||||
+ f" from IP `{client_ip}.`",
|
||||
f" from IP `{client_ip}.`",
|
||||
)
|
||||
else:
|
||||
# The client's IP address is private
|
||||
logger.info(
|
||||
f"Login failed for user `{credentials['username']}`"
|
||||
+ f" from private IP `{client_ip}.`",
|
||||
f" from private IP `{client_ip}.`",
|
||||
)
|
||||
|
0
src/paperless/tests/__init__.py
Normal file
0
src/paperless/tests/__init__.py
Normal file
@@ -56,61 +56,57 @@ urlpatterns = [
|
||||
include(
|
||||
[
|
||||
re_path(
|
||||
r"^auth/",
|
||||
"^auth/",
|
||||
include(
|
||||
("rest_framework.urls", "rest_framework"),
|
||||
namespace="rest_framework",
|
||||
),
|
||||
),
|
||||
re_path(
|
||||
r"^search/autocomplete/",
|
||||
"^search/autocomplete/",
|
||||
SearchAutoCompleteView.as_view(),
|
||||
name="autocomplete",
|
||||
),
|
||||
re_path(r"^statistics/", StatisticsView.as_view(), name="statistics"),
|
||||
re_path("^statistics/", StatisticsView.as_view(), name="statistics"),
|
||||
re_path(
|
||||
r"^documents/post_document/",
|
||||
"^documents/post_document/",
|
||||
PostDocumentView.as_view(),
|
||||
name="post_document",
|
||||
),
|
||||
re_path(
|
||||
r"^documents/bulk_edit/",
|
||||
"^documents/bulk_edit/",
|
||||
BulkEditView.as_view(),
|
||||
name="bulk_edit",
|
||||
),
|
||||
re_path(
|
||||
r"^documents/selection_data/",
|
||||
"^documents/selection_data/",
|
||||
SelectionDataView.as_view(),
|
||||
name="selection_data",
|
||||
),
|
||||
re_path(
|
||||
r"^documents/bulk_download/",
|
||||
"^documents/bulk_download/",
|
||||
BulkDownloadView.as_view(),
|
||||
name="bulk_download",
|
||||
),
|
||||
re_path(
|
||||
r"^remote_version/",
|
||||
"^remote_version/",
|
||||
RemoteVersionView.as_view(),
|
||||
name="remoteversion",
|
||||
),
|
||||
re_path("^ui_settings/", UiSettingsView.as_view(), name="ui_settings"),
|
||||
re_path(
|
||||
r"^ui_settings/",
|
||||
UiSettingsView.as_view(),
|
||||
name="ui_settings",
|
||||
),
|
||||
re_path(
|
||||
r"^acknowledge_tasks/",
|
||||
"^acknowledge_tasks/",
|
||||
AcknowledgeTasksView.as_view(),
|
||||
name="acknowledge_tasks",
|
||||
),
|
||||
re_path(
|
||||
r"^mail_accounts/test/",
|
||||
"^mail_accounts/test/",
|
||||
MailAccountTestView.as_view(),
|
||||
name="mail_accounts_test",
|
||||
),
|
||||
path("token/", views.obtain_auth_token),
|
||||
]
|
||||
+ api_router.urls,
|
||||
*api_router.urls,
|
||||
],
|
||||
),
|
||||
),
|
||||
re_path(r"^favicon.ico$", FaviconView.as_view(), name="favicon"),
|
||||
|
Reference in New Issue
Block a user