mirror of
https://github.com/suitenumerique/docs.git
synced 2026-08-17 21:25:43 +02:00
🚨(backend) lint code with new ruff 0.16
New ruff version need to lint the code again and adapt exceptions
This commit is contained in:
@@ -110,7 +110,7 @@ def pytest_sessionstart(session):
|
|||||||
len(_PRE_EXISTING_OBJECTS),
|
len(_PRE_EXISTING_OBJECTS),
|
||||||
bucket_name,
|
bucket_name,
|
||||||
)
|
)
|
||||||
except Exception: # pylint: disable=broad-except # noqa: BLE001
|
except Exception: # pylint: disable=broad-except
|
||||||
# MinIO may be unreachable (e.g. storage-less unit runs): disable cleanup.
|
# MinIO may be unreachable (e.g. storage-less unit runs): disable cleanup.
|
||||||
_PRE_EXISTING_OBJECTS = None
|
_PRE_EXISTING_OBJECTS = None
|
||||||
logger.warning(
|
logger.warning(
|
||||||
@@ -155,5 +155,5 @@ def pytest_sessionfinish(session, exitstatus): # pylint: disable=unused-argumen
|
|||||||
deleted,
|
deleted,
|
||||||
bucket_name,
|
bucket_name,
|
||||||
)
|
)
|
||||||
except Exception: # pylint: disable=broad-except # noqa: BLE001
|
except Exception: # pylint: disable=broad-except
|
||||||
logger.warning("S3 test cleanup failed", exc_info=True)
|
logger.warning("S3 test cleanup failed", exc_info=True)
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ def populate_attachments_on_all_documents(apps, schema_editor):
|
|||||||
response = default_storage.connection.meta.client.get_object(
|
response = default_storage.connection.meta.client.get_object(
|
||||||
Bucket=default_storage.bucket_name, Key=f"{document.pk!s}/file"
|
Bucket=default_storage.bucket_name, Key=f"{document.pk!s}/file"
|
||||||
)
|
)
|
||||||
except (FileNotFoundError, ClientError):
|
except FileNotFoundError, ClientError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
content = response["Body"].read().decode("utf-8")
|
content = response["Body"].read().decode("utf-8")
|
||||||
|
|||||||
@@ -1064,7 +1064,7 @@ class Document(MP_Node, BaseModel):
|
|||||||
if self._content is None and self.id:
|
if self._content is None and self.id:
|
||||||
try:
|
try:
|
||||||
response = self.get_content_response()
|
response = self.get_content_response()
|
||||||
except (FileNotFoundError, ClientError):
|
except FileNotFoundError, ClientError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self._content = response["Body"].read().decode("utf-8")
|
self._content = response["Body"].read().decode("utf-8")
|
||||||
@@ -2101,7 +2101,7 @@ class Invitation(BaseModel):
|
|||||||
roles = self.document.accesses.filter(
|
roles = self.document.accesses.filter(
|
||||||
models.Q(user=user) | models.Q(team__in=teams),
|
models.Q(user=user) | models.Q(team__in=teams),
|
||||||
).values_list("role", flat=True)
|
).values_list("role", flat=True)
|
||||||
except (self._meta.model.DoesNotExist, IndexError):
|
except self._meta.model.DoesNotExist, IndexError:
|
||||||
roles = []
|
roles = []
|
||||||
|
|
||||||
is_admin_or_owner = bool(
|
is_admin_or_owner = bool(
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class BaseDocumentIndexer(ABC):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
||||||
def search( # noqa : PLR0913
|
def search( # noqa : PLR0913, PLR0917
|
||||||
self,
|
self,
|
||||||
q: str,
|
q: str,
|
||||||
token: str,
|
token: str,
|
||||||
@@ -248,7 +248,7 @@ class FindDocumentIndexer(BaseDocumentIndexer):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
||||||
def search( # noqa : PLR0913
|
def search( # noqa : PLR0913, PLR0917
|
||||||
self,
|
self,
|
||||||
q: str,
|
q: str,
|
||||||
token: str,
|
token: str,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def _process_row(row, job, counters):
|
|||||||
for inactive_email in inactive_emails:
|
for inactive_email in inactive_emails:
|
||||||
try:
|
try:
|
||||||
validate_email(inactive_email)
|
validate_email(inactive_email)
|
||||||
except (ValidationError, ValueError):
|
except ValidationError, ValueError:
|
||||||
job.send_reconciliation_error_email(
|
job.send_reconciliation_error_email(
|
||||||
recipient_email=active_email, other_email=inactive_email
|
recipient_email=active_email, other_email=inactive_email
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pytestmark = pytest.mark.django_db
|
|||||||
)
|
)
|
||||||
@pytest.mark.usefixtures("indexer_settings")
|
@pytest.mark.usefixtures("indexer_settings")
|
||||||
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
||||||
def test_api_documents_search_success( # noqa : PLR0913
|
def test_api_documents_search_success( # noqa : PLR0913, PLR0917
|
||||||
mock_search_using_indexer,
|
mock_search_using_indexer,
|
||||||
mock_search_using_database,
|
mock_search_using_database,
|
||||||
activated_flags,
|
activated_flags,
|
||||||
|
|||||||
@@ -883,7 +883,7 @@ def test_models_documents_get_abilities_preset_role(django_assert_num_queries):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
# pylint: disable=too-many-arguments, too-many-positional-arguments
|
||||||
def test_models_documents_get_abilities_children_destroy( # noqa: PLR0913
|
def test_models_documents_get_abilities_children_destroy( # noqa: PLR0913, PLR0917
|
||||||
is_authenticated,
|
is_authenticated,
|
||||||
is_creator,
|
is_creator,
|
||||||
role,
|
role,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def get_release():
|
|||||||
with open(os.path.join(BASE_DIR, "pyproject.toml"), "rb") as f:
|
with open(os.path.join(BASE_DIR, "pyproject.toml"), "rb") as f:
|
||||||
pyproject_data = tomllib.load(f)
|
pyproject_data = tomllib.load(f)
|
||||||
return pyproject_data["project"]["version"]
|
return pyproject_data["project"]["version"]
|
||||||
except (FileNotFoundError, KeyError):
|
except FileNotFoundError, KeyError:
|
||||||
return "NA" # Default: not available
|
return "NA" # Default: not available
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user