From bb859d8f2c7e011e2f54b7a5d9a00f48bf457586 Mon Sep 17 00:00:00 2001 From: Pamella Bezerra Date: Mon, 27 May 2024 12:19:18 -0300 Subject: [PATCH 1/3] Fix clean command --- Makefile | 2 +- poetry.lock | 2 +- pyproject.toml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e17c28a..0e90669 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ clean: ## remove generated byte code, coverage reports, and build artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + - coverage erase + poetry run coverage erase rm -fr build/ rm -fr dist/ rm -fr *.egg-info diff --git a/poetry.lock b/poetry.lock index 021b706..06e5f7d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2083,4 +2083,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "f8007b3c0dd29e57b73e43b8fdd863e9ee0c3e0872867ea0135acc94027bd4bc" +content-hash = "6849c9552a5762796a199ee555173f4f003a697e233e6b3affacfd814ff43472" diff --git a/pyproject.toml b/pyproject.toml index 021d1f1..fbbb6f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ docutils = "^0.20.1" twine = "^5.1.0" ruff = "^0.4.5" prospector = "^1.10.3" +coverage = "^7.5.2" [tool.poetry.group.test.dependencies] From dafd3f8cd1c78751bcecab500a5ea187fe17c6bc Mon Sep 17 00:00:00 2001 From: Pamella Bezerra Date: Mon, 27 May 2024 12:21:43 -0300 Subject: [PATCH 2/3] Handle prospector warnings --- drf_rw_serializers/generics.py | 3 ++- tests/test_generics.py | 16 ++++++++-------- tests/test_mixins.py | 8 ++++---- tests/test_viewsets.py | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drf_rw_serializers/generics.py b/drf_rw_serializers/generics.py index 42c462c..506500d 100644 --- a/drf_rw_serializers/generics.py +++ b/drf_rw_serializers/generics.py @@ -53,7 +53,8 @@ def get_serializer_class(self): "`get_serializer_class()` method." % self.__class__.__name__ ) return self.get_read_serializer_class() - elif self.request.method in ["POST", "PUT", "PATCH", "DELETE"]: + + if self.request.method in ["POST", "PUT", "PATCH", "DELETE"]: assert ( getattr(self, "write_serializer_class", None) is not None or self.serializer_class is not None diff --git a/tests/test_generics.py b/tests/test_generics.py index 98cd434..50b0ec2 100644 --- a/tests/test_generics.py +++ b/tests/test_generics.py @@ -155,7 +155,7 @@ class WriteSerializerClassProvided(generics.GenericAPIView): class OrderListCreateEndpointTests(BaseTestCase, TestListRequestSuccess, TestCreateRequestSuccess): def setUp(self): - super(OrderListCreateEndpointTests, self).setUp() + super().setUp() TestCreateRequestSuccess.setUp(self) self.view_url = reverse("list_create") self.list_serializer_class = OrderListSerializer @@ -167,7 +167,7 @@ class OrderRetrieveUpdateDestroyEndpointTests( BaseTestCase, TestRetrieveRequestSuccess, TestUpdateRequestSuccess ): def setUp(self): - super(OrderRetrieveUpdateDestroyEndpointTests, self).setUp() + super().setUp() TestUpdateRequestSuccess.setUp(self) self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) @@ -179,7 +179,7 @@ def setUp(self): class OrderListWithoutReadSerializerEndpointTests(BaseTestCase, TestListRequestSuccess): def setUp(self): - super(OrderListWithoutReadSerializerEndpointTests, self).setUp() + super().setUp() self.view_url = reverse("list_without_read_serializer") self.list_serializer_class = OrderListSerializer @@ -188,7 +188,7 @@ class OrderRetrieveUpdateEndpointTests( BaseTestCase, TestRetrieveRequestSuccess, TestUpdateRequestSuccess ): def setUp(self): - super(OrderRetrieveUpdateEndpointTests, self).setUp() + super().setUp() TestUpdateRequestSuccess.setUp(self) self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) @@ -200,7 +200,7 @@ def setUp(self): class OrderCreateWithGenericEndpointTests(BaseTestCase, TestCreateRequestSuccess): def setUp(self): - super(OrderCreateWithGenericEndpointTests, self).setUp() + super().setUp() self.view_url = reverse("create") self.list_serializer_class = OrderListSerializer self.create_in_serializer_class = OrderCreateSerializer @@ -209,7 +209,7 @@ def setUp(self): class OrderUpdateWithGenericEndpointTests(BaseTestCase, TestUpdateRequestSuccess): def setUp(self): - super(OrderUpdateWithGenericEndpointTests, self).setUp() + super().setUp() TestUpdateRequestSuccess.setUp(self) self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) @@ -221,14 +221,14 @@ def setUp(self): class OrderListWithGenericEndpointTests(BaseTestCase, TestListRequestSuccess): def setUp(self): - super(OrderListWithGenericEndpointTests, self).setUp() + super().setUp() self.view_url = reverse("list") self.list_serializer_class = OrderListSerializer class OrderRetrieveWithGenericEndpointTests(BaseTestCase, TestRetrieveRequestSuccess): def setUp(self): - super(OrderRetrieveWithGenericEndpointTests, self).setUp() + super().setUp() self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) self.view_url = reverse("retrieve", kwargs={"pk": self.object.pk}) diff --git a/tests/test_mixins.py b/tests/test_mixins.py index 57f1792..af6c17e 100644 --- a/tests/test_mixins.py +++ b/tests/test_mixins.py @@ -22,7 +22,7 @@ class OrderCreateWithMixinEndpointTests(BaseTestCase, TestCreateRequestSuccess): def setUp(self): - super(OrderCreateWithMixinEndpointTests, self).setUp() + super().setUp() self.view_url = reverse("create_mixin") self.list_serializer_class = OrderListSerializer self.create_in_serializer_class = OrderCreateSerializer @@ -31,7 +31,7 @@ def setUp(self): class OrderUpdateWithMixinEndpointTests(BaseTestCase, TestUpdateRequestSuccess): def setUp(self): - super(OrderUpdateWithMixinEndpointTests, self).setUp() + super().setUp() self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) self.view_url = reverse("update_mixin", kwargs={"pk": self.object.pk}) @@ -42,14 +42,14 @@ def setUp(self): class OrderListWithMixinEndpointTests(BaseTestCase, TestListRequestSuccess): def setUp(self): - super(OrderListWithMixinEndpointTests, self).setUp() + super().setUp() self.view_url = reverse("list_mixin") self.list_serializer_class = OrderListSerializer class OrderRetrieveWithMixinEndpointTests(BaseTestCase, TestRetrieveRequestSuccess): def setUp(self): - super(OrderRetrieveWithMixinEndpointTests, self).setUp() + super().setUp() self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) self.view_url = reverse("retrieve_mixin", kwargs={"pk": self.object.pk}) diff --git a/tests/test_viewsets.py b/tests/test_viewsets.py index 8b27688..9ae3a9a 100644 --- a/tests/test_viewsets.py +++ b/tests/test_viewsets.py @@ -22,7 +22,7 @@ class OrderViewsetListCreateTests(BaseTestCase, TestListRequestSuccess, TestCreateRequestSuccess): def setUp(self): - super(OrderViewsetListCreateTests, self).setUp() + super().setUp() self.view_url = reverse("viewset_list_create") self.list_serializer_class = OrderListSerializer self.create_in_serializer_class = OrderCreateSerializer @@ -33,7 +33,7 @@ class OrderViewsetRetrieveUpdateDestroyTests( BaseTestCase, TestRetrieveRequestSuccess, TestUpdateRequestSuccess ): def setUp(self): - super(OrderViewsetRetrieveUpdateDestroyTests, self).setUp() + super().setUp() self.object = baker.make("example_app.Order") baker.make("example_app.OrderedMeal", order=self.object, _quantity=2) self.view_url = reverse("viewset_retrieve_update_destroy", kwargs={"pk": self.object.pk}) From 1dfd0aecaf0af733248f958404c4f4f7ed62b8fa Mon Sep 17 00:00:00 2001 From: Pamella Bezerra Date: Mon, 27 May 2024 12:26:20 -0300 Subject: [PATCH 3/3] Use same spacing --- pyproject.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fbbb6f3..882ef8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,13 +41,13 @@ build-backend = "poetry.core.masonry.api" [tool.ruff] exclude = [ - "env", - "venv", - ".pyenv", - ".pytest_cache", - "*/__pycache__/*", - "*/migrations/*", - "docs", + "env", + "venv", + ".pyenv", + ".pytest_cache", + "*/__pycache__/*", + "*/migrations/*", + "docs", ] line-length = 100 target-version = "py38" @@ -59,8 +59,8 @@ line-ending = "auto" [tool.ruff.lint] extend-select = [ - # isort - "I", + # isort + "I", ] [tool.ruff.lint.isort.sections]