Skip to content

Commit 33ac5b7

Browse files
authored
Ruff: Add and fix PLW0604 (#11773)
1 parent 2f7b76e commit 33ac5b7

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ select = [
7676
"PLC01", "PLC0205", "PLC0208", "PLC0414", "PLC18", "PLC24", "PLC28", "PLC3",
7777
"PLE",
7878
"PLR01", "PLR02", "PLR04", "PLR0915", "PLR1716", "PLR172", "PLR1733", "PLR1736", "PLR5", "PLR6104", "PLR6201",
79-
"PLW01", "PLW02", "PLW04", "PLW07", "PLW1", "PLW2", "PLW3",
79+
"PLW01", "PLW02", "PLW04", "PLW0604", "PLW07", "PLW1", "PLW2", "PLW3",
8080
"TRY003", "TRY004", "TRY2", "TRY300", "TRY401",
8181
"FLY",
8282
"NPY",

unittests/test_rest_framework.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
import json
23
import logging
34
import pathlib
@@ -151,6 +152,7 @@
151152
REIMPORTER_MOCK_RETURN_VALUE = None, 0, 0, 0, 0, 0, MagicMock()
152153

153154

155+
@functools.cache
154156
def get_open_api3_json_schema():
155157
generator_class = spectacular_settings.DEFAULT_GENERATOR_CLASS
156158
generator = generator_class()
@@ -163,11 +165,6 @@ def get_open_api3_json_schema():
163165
return schema
164166

165167

166-
# use ugly global to avoid generating the schema for every test/method (as it's slow)
167-
global open_api3_json_schema
168-
open_api3_json_schema = get_open_api3_json_schema()
169-
170-
171168
def skipIfNotSubclass(baseclass):
172169
def decorate(f):
173170
def wrapper(self, *args, **kwargs):
@@ -363,7 +360,7 @@ def setUp(self):
363360
self.client = APIClient()
364361
self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key)
365362
self.url = reverse(self.viewname + "-list")
366-
self.schema = open_api3_json_schema
363+
self.schema = get_open_api3_json_schema()
367364

368365
def setUp_not_authorized(self):
369366
testuser = User.objects.get(id=3)
@@ -465,7 +462,7 @@ def test_detail_configuration_not_authorized(self):
465462
class ListRequestTest(RESTEndpointTest):
466463
@skipIfNotSubclass(ListModelMixin)
467464
def test_list(self):
468-
# print(open_api3_json_schema)
465+
# print(get_open_api3_json_schema())
469466
# validator = ResponseValidator(spec)
470467

471468
check_for_tags = False

0 commit comments

Comments
 (0)