Skip to content

Commit c4cab6b

Browse files
committed
Update linting errors
1 parent 7b17f60 commit c4cab6b

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

caching/private_api/decorators.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ def wrapped_view(*args, **kwargs) -> Response:
7474

7575
def _check_if_valid_non_public_request(request):
7676
auth = backend.JSONWebTokenAuthentication()
77-
is_authenticated = auth.authenticate(request)
7877

79-
return is_authenticated
78+
return auth.authenticate(request)
8079

8180

8281
def _retrieve_response_from_cache_or_calculate(
@@ -110,12 +109,12 @@ def _retrieve_response_from_cache_or_calculate(
110109
request: Request = args[1]
111110
if not is_public:
112111
return _calculate_response_from_view(
113-
view_function, is_public=is_public, *args, **kwargs
112+
view_function, *args, is_public=is_public, **kwargs
114113
)
115114

116115
if is_caching_v2_enabled() and not is_reserved_namespace:
117116
return _calculate_response_from_view(
118-
view_function, is_public=is_public, *args, **kwargs
117+
view_function, *args, is_public=is_public, **kwargs
119118
)
120119

121120
cache_management = kwargs.pop(
@@ -146,7 +145,7 @@ def _calculate_response_and_save_in_cache(
146145
view_function, timeout, cache_management, cache_entry_key, *args, **kwargs
147146
) -> Response:
148147
response: Response = _calculate_response_from_view(
149-
view_function, is_public=True, *args, **kwargs
148+
view_function, *args, is_public=True, **kwargs
150149
)
151150
if timeout == 0:
152151
return response

metrics/data/managers/core_models/time_series.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from django.db.models.query_utils import Q
1414
from django.utils import timezone
1515

16-
from metrics.api.permissions.fluent_permissions import validate_permissions_for_non_public
16+
from metrics.api.permissions.fluent_permissions import (
17+
validate_permissions_for_non_public,
18+
)
1719
from metrics.data.models import RBACPermission
1820

1921
ALLOWABLE_METRIC_VALUE_RANGE_TYPE = tuple[str | float | int, str | float | int]

tests/unit/public_api/v2/views/test_base.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from public_api.version_02.views.base import BaseNestedAPITimeSeriesViewV2
55

6+
67
class TestNestedTimeSeriesView(BaseNestedAPITimeSeriesViewV2):
78
"""
89
Minimal concrete implementation so BaseNestedAPITimeSeriesView can be instantiated
@@ -13,6 +14,7 @@ class TestNestedTimeSeriesView(BaseNestedAPITimeSeriesViewV2):
1314

1415
serializer_class = mock.MagicMock
1516

17+
1618
class TestBaseNestedAPITimeSeriesViewV2:
1719
def test_raises_error_for_lookup_field_property(self):
1820
"""
@@ -42,20 +44,23 @@ def test_raises_error_for_serializer_class_property(self):
4244
with pytest.raises(NotImplementedError):
4345
base_view.serializer_class
4446

47+
4548
class TestGetAddsPrivateHeaderForNonPublicRequests:
4649
"""
4750
Tests for the newly added private Cache-Control header behaviour in the `get()` method.
4851
"""
4952

50-
@mock.patch("public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate")
53+
@mock.patch(
54+
"public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate"
55+
)
5156
@mock.patch("public_api.version_02.views.base.Response")
5257
@mock.patch("public_api.version_02.views.base.APITimeSeriesRequestSerializerv2")
5358
def test_private_header_added_when_valid_jwt(
5459
self,
5560
mock_request_serializer_class: mock.MagicMock,
5661
mock_response_class: mock.MagicMock,
57-
mock_backend_auth_authenticate: mock.MagicMock
58-
):
62+
mock_backend_auth_authenticate: mock.MagicMock,
63+
):
5964
"""
6065
Given `backend.JSONWebTokenAuthentication.authenticate()` returns True
6166
When `get()` is called
@@ -90,7 +95,9 @@ def test_private_header_added_when_valid_jwt(
9095
)
9196
assert response == mocked_response
9297

93-
@mock.patch("public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate")
98+
@mock.patch(
99+
"public_api.version_02.views.base.backend.JSONWebTokenAuthentication.authenticate"
100+
)
94101
@mock.patch("public_api.version_02.views.base.Response")
95102
@mock.patch("public_api.version_02.views.base.APITimeSeriesRequestSerializerv2")
96103
def test_private_header_not_added_when_is_valid_non_public_request_is_false(
@@ -132,4 +139,4 @@ def test_private_header_not_added_when_is_valid_non_public_request_is_false(
132139
# Then
133140
mock_backend_auth_authenticate.assert_called_once_with(mocked_request)
134141
mocked_response.__setitem__.assert_not_called()
135-
assert response == mocked_response
142+
assert response == mocked_response

tests/unit/public_api/views/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def test_private_header_added_when_valid_jwt(
5757
self,
5858
mock_request_serializer_class: mock.MagicMock,
5959
mock_response_class: mock.MagicMock,
60-
mock_backend_auth_authenticate: mock.MagicMock
61-
):
60+
mock_backend_auth_authenticate: mock.MagicMock,
61+
):
6262
"""
6363
Given `backend.JSONWebTokenAuthentication.authenticate()` returns True
6464
When `get()` is called

0 commit comments

Comments
 (0)