Skip to content

Commit c9f9fc3

Browse files
committed
Ruff: Add and fix PLW0604
1 parent 88e0409 commit c9f9fc3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
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", "PLC3",
7777
"PLE",
7878
"PLR01", "PLR0203", "PLR0206", "PLR0915", "PLR1716", "PLR172", "PLR1733", "PLR1736",
79-
"PLW0108", "PLW0120", "PLW0127", "PLW0129", "PLW013", "PLW017", "PLW02", "PLW04", "PLW07", "PLW1", "PLW2", "PLW3",
79+
"PLW0108", "PLW0120", "PLW0127", "PLW0129", "PLW013", "PLW017", "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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from collections import OrderedDict
55
from enum import Enum
66
from json import dumps
7+
import functools
78

89
# from drf_spectacular.renderers import OpenApiJsonRenderer
910
from unittest.mock import ANY, MagicMock, call, patch
@@ -150,7 +151,7 @@
150151
IMPORTER_MOCK_RETURN_VALUE = None, 0, 0, 0, 0, 0, MagicMock()
151152
REIMPORTER_MOCK_RETURN_VALUE = None, 0, 0, 0, 0, 0, MagicMock()
152153

153-
154+
@functools.cache
154155
def get_open_api3_json_schema():
155156
generator_class = spectacular_settings.DEFAULT_GENERATOR_CLASS
156157
generator = generator_class()
@@ -163,11 +164,6 @@ def get_open_api3_json_schema():
163164
return schema
164165

165166

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-
171167
def skipIfNotSubclass(baseclass):
172168
def decorate(f):
173169
def wrapper(self, *args, **kwargs):
@@ -363,7 +359,7 @@ def setUp(self):
363359
self.client = APIClient()
364360
self.client.credentials(HTTP_AUTHORIZATION="Token " + token.key)
365361
self.url = reverse(self.viewname + "-list")
366-
self.schema = open_api3_json_schema
362+
self.schema = get_open_api3_json_schema()
367363

368364
def setUp_not_authorized(self):
369365
testuser = User.objects.get(id=3)
@@ -465,7 +461,7 @@ def test_detail_configuration_not_authorized(self):
465461
class ListRequestTest(RESTEndpointTest):
466462
@skipIfNotSubclass(ListModelMixin)
467463
def test_list(self):
468-
# print(open_api3_json_schema)
464+
# print(get_open_api3_json_schema())
469465
# validator = ResponseValidator(spec)
470466

471467
check_for_tags = False

0 commit comments

Comments
 (0)