From 093b948c39a49961abfea37c85c3c25e64ee43c6 Mon Sep 17 00:00:00 2001
From: Yoann Schneider <yschneider@teklia.com>
Date: Mon, 15 Apr 2024 20:02:23 +0200
Subject: [PATCH] Introduce UP004

---
 arkindex/documents/dates.py                       | 4 ++--
 arkindex/documents/indexer.py                     | 2 +-
 arkindex/documents/tests/test_edit_elementpath.py | 2 +-
 arkindex/ponos/serializer_fields.py               | 2 +-
 arkindex/process/api.py                           | 2 +-
 arkindex/process/builder.py                       | 2 +-
 arkindex/project/argparse.py                      | 2 +-
 arkindex/project/aws.py                           | 2 +-
 arkindex/project/fields.py                        | 2 +-
 arkindex/project/mixins.py                        | 8 ++++----
 arkindex/project/tests/__init__.py                | 2 +-
 arkindex/project/validators.py                    | 6 +++---
 arkindex/users/tests/test_jobs.py                 | 2 +-
 ruff.toml                                         | 2 ++
 14 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/arkindex/documents/dates.py b/arkindex/documents/dates.py
index dc3012bef8..6e0cdd57f7 100644
--- a/arkindex/documents/dates.py
+++ b/arkindex/documents/dates.py
@@ -16,7 +16,7 @@ class DatePrecision(Enum):
     Day = "d"
 
 
-class InterpretedDate(object):
+class InterpretedDate:
 
     def __init__(self, year, month=None, day=None, type=DateType.Exact):
         self.year = int(year)
@@ -73,7 +73,7 @@ class InterpretedDate(object):
         return "-".join("{:02d}".format(e) for e in tuple(self) if e)
 
 
-class InterpretedDateMixin(object):
+class InterpretedDateMixin:
     """
     Adds on-demand date parsing from a text field to InterpretedDates.
     Requires a `raw_dates` property that returns the date string.
diff --git a/arkindex/documents/indexer.py b/arkindex/documents/indexer.py
index 203722ec31..37f7e200e4 100644
--- a/arkindex/documents/indexer.py
+++ b/arkindex/documents/indexer.py
@@ -59,7 +59,7 @@ INNER JOIN documents_elementtype elementtype ON (element.type_id = elementtype.i
 """
 
 
-class Indexer(object):
+class Indexer:
 
     # The query yielding all the elements to run on will look for all the child elements of all indexable elements
     # The joins can take a very long time, so the query gets split into one to fetch all the indexable elements,
diff --git a/arkindex/documents/tests/test_edit_elementpath.py b/arkindex/documents/tests/test_edit_elementpath.py
index ac0f945e98..5633763cea 100644
--- a/arkindex/documents/tests/test_edit_elementpath.py
+++ b/arkindex/documents/tests/test_edit_elementpath.py
@@ -358,7 +358,7 @@ class TestEditElementPath(FixtureTestCase):
         # B will only have one remaining path: the first path that got picked by remove_child for the update.
         # The other path will have been deleted. We can therefore get this remaining path and compare it by its ID
         # to the two paths that we had before, and pick the parent that was in the old version of this path.
-        class FirstParent(object):
+        class FirstParent:
             def __str__(self):
                 path_id = elements["B"].paths.get().id
                 if path1.id == path_id:
diff --git a/arkindex/ponos/serializer_fields.py b/arkindex/ponos/serializer_fields.py
index 2823133392..1bd83378c8 100644
--- a/arkindex/ponos/serializer_fields.py
+++ b/arkindex/ponos/serializer_fields.py
@@ -56,7 +56,7 @@ class Base64Field(serializers.CharField):
         return base64.b64encode(obj)
 
 
-class CurrentProcessDefault(object):
+class CurrentProcessDefault:
     """
     Use the process of the currently authenticated task as a default value.
     If Ponos task authentication is not in use, returns None.
diff --git a/arkindex/process/api.py b/arkindex/process/api.py
index f527305661..6b6e2416bf 100644
--- a/arkindex/process/api.py
+++ b/arkindex/process/api.py
@@ -270,7 +270,7 @@ class ProcessList(ProcessACLMixin, ListAPIView):
         return qs.order_by("-date_order")
 
 
-class ProcessQuerysetMixin(object):
+class ProcessQuerysetMixin:
     """
     Optimized queryset for Retrieve/Update/PartialUpdate/Destroy/RetryProcess
     """
diff --git a/arkindex/process/builder.py b/arkindex/process/builder.py
index 74619b170e..af735708e2 100644
--- a/arkindex/process/builder.py
+++ b/arkindex/process/builder.py
@@ -16,7 +16,7 @@ from arkindex.images.models import ImageServer
 from arkindex.ponos.models import GPU, Task, task_token_default
 
 
-class ProcessBuilder(object):
+class ProcessBuilder:
 
     def __init__(self, process) -> None:
         self.process = process
diff --git a/arkindex/project/argparse.py b/arkindex/project/argparse.py
index bbb3dcf17c..66cbd69469 100644
--- a/arkindex/project/argparse.py
+++ b/arkindex/project/argparse.py
@@ -7,7 +7,7 @@ from arkindex.process.models import Process, Repository, WorkerVersion
 from arkindex.users.models import User
 
 
-class ModelArgument(object):
+class ModelArgument:
     model = None
     text_search_field = "name"
     text_search_lookup = "icontains"
diff --git a/arkindex/project/aws.py b/arkindex/project/aws.py
index 659f37326a..1bde384677 100644
--- a/arkindex/project/aws.py
+++ b/arkindex/project/aws.py
@@ -88,7 +88,7 @@ def _retry_delete_predicate(exception):
     )
 
 
-class S3FileMixin(object):
+class S3FileMixin:
 
     def get_s3_object(self):
         if not self.s3_bucket or not self.s3_key:
diff --git a/arkindex/project/fields.py b/arkindex/project/fields.py
index e66f28bb13..69f974302a 100644
--- a/arkindex/project/fields.py
+++ b/arkindex/project/fields.py
@@ -127,7 +127,7 @@ class LastItemTransform(Transform):
         return self.base_field
 
 
-class LastItemTransformFactory(object):
+class LastItemTransformFactory:
     """
     Create a LastItemTransform with a given base field
     """
diff --git a/arkindex/project/mixins.py b/arkindex/project/mixins.py
index 6f04942aa2..744da257c3 100644
--- a/arkindex/project/mixins.py
+++ b/arkindex/project/mixins.py
@@ -13,7 +13,7 @@ from arkindex.users.models import Role
 from arkindex.users.utils import filter_rights, get_max_level, has_access
 
 
-class ACLMixin(object):
+class ACLMixin:
     """
     Access control mixin using the generic Right table.
     """
@@ -140,7 +140,7 @@ class ProcessACLMixin(ACLMixin):
         return get_max_level(self.user, process.corpus)
 
 
-class SelectionMixin(object):
+class SelectionMixin:
 
     def get_selection(self, corpus_id=None):
         assert settings.ARKINDEX_FEATURES["selection"], "Selection feature is unavailable"
@@ -165,7 +165,7 @@ class DeprecatedAPIException(APIException):
     default_code = "deprecated"
 
 
-class DeprecatedMixin(object):
+class DeprecatedMixin:
     # Add this mixin to an APIView to make it deprecated.
 
     serializer_class = DeprecatedExceptionSerializer
@@ -196,7 +196,7 @@ class DeprecatedMixin(object):
             raise DeprecatedAPIException(detail=getattr(self, "deprecation_message", None))
 
 
-class CachedViewMixin(object):
+class CachedViewMixin:
     """
     Add this mixin to any class-based view to cache it.
     """
diff --git a/arkindex/project/tests/__init__.py b/arkindex/project/tests/__init__.py
index cca5e05eb7..9db13cd987 100644
--- a/arkindex/project/tests/__init__.py
+++ b/arkindex/project/tests/__init__.py
@@ -96,7 +96,7 @@ class _AssertExactQueriesContext(CaptureQueriesContext):
         self.test_case.assertEqual(expected_sql, actual_sql)
 
 
-class FixtureMixin(object):
+class FixtureMixin:
     """
     Add the database fixture to a test case
     """
diff --git a/arkindex/project/validators.py b/arkindex/project/validators.py
index 15fb732317..980e263686 100644
--- a/arkindex/project/validators.py
+++ b/arkindex/project/validators.py
@@ -2,7 +2,7 @@ from django.core import validators
 from rest_framework import serializers
 
 
-class XorValidator(object):
+class XorValidator:
     """
     A generic validator for when two fields can't be used simultaneously
     """
@@ -45,7 +45,7 @@ class ConditionalUniqueValidator(serializers.UniqueTogetherValidator):
         return super().__call__(attrs, serializer)
 
 
-class ForbiddenValidator(object):
+class ForbiddenValidator:
     """
     A validator that will show an error message any time a value is set.
 
@@ -65,7 +65,7 @@ class ForbiddenValidator(object):
             raise serializers.ValidationError(self.message)
 
 
-class HiddenCallableValidatorMixin(object):
+class HiddenCallableValidatorMixin:
     """
     Implements a workaround for some issues with error messages in DRF
     and with drf-spectacular OpenAPI schema generation when the `limit_value`
diff --git a/arkindex/users/tests/test_jobs.py b/arkindex/users/tests/test_jobs.py
index e008cb2eeb..ad20177b79 100644
--- a/arkindex/users/tests/test_jobs.py
+++ b/arkindex/users/tests/test_jobs.py
@@ -10,7 +10,7 @@ from rq.job import JobStatus
 from arkindex.project.tests import FixtureAPITestCase
 
 
-class MockedJob(object):
+class MockedJob:
 
     def __init__(self, id=None, user_id=None, status=JobStatus.QUEUED, **kwargs):
         self.id = id or str(uuid4())
diff --git a/ruff.toml b/ruff.toml
index 943a2b2ee4..066da2b9e2 100644
--- a/ruff.toml
+++ b/ruff.toml
@@ -25,6 +25,8 @@ select = [
     "RET",
     # eradicate
     "ERA",
+    # useless-object-inheritance
+    "UP004",
 ]
 ignore = ["E501", "RET502", "RET503"]
 
-- 
GitLab