Skip to content

Commit

Permalink
Merge pull request #79 from vintasoftware/fix/warnings
Browse files Browse the repository at this point in the history
Address `prospector` warnings
  • Loading branch information
pamella authored May 27, 2024
2 parents 2a339b7 + 1dfd0ae commit 6810754
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drf_rw_serializers/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -40,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"
Expand All @@ -58,8 +59,8 @@ line-ending = "auto"

[tool.ruff.lint]
extend-select = [
# isort
"I",
# isort
"I",
]

[tool.ruff.lint.isort.sections]
Expand Down
16 changes: 8 additions & 8 deletions tests/test_generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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})
Expand Down
8 changes: 4 additions & 4 deletions tests/test_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand All @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions tests/test_viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down

0 comments on commit 6810754

Please sign in to comment.