From cc217572447b1e96d457e2a955d1c5eb7e52c105 Mon Sep 17 00:00:00 2001 From: MarkoM-dot <83985775+MarkoM-dot@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:21:01 +0100 Subject: [PATCH 1/3] fix(compat): catch AttributeError since EntryPoints object has no get() --- .pre-commit-config.yaml | 2 +- rest_framework/compat.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64ec37770f..8bb131a047 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 3.9.0 + rev: 5.0.0 hooks: - id: flake8 additional_dependencies: diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 7e80704e11..e4293cebf1 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -82,7 +82,7 @@ def apply_markdown(text): ) md_filter_add_syntax_highlight(md) return md.convert(text) -except ImportError: +except (ImportError, AttributeError): apply_markdown = None markdown = None From 305edf5c9f0f6f39dfe827f0f3f935149772b7b0 Mon Sep 17 00:00:00 2001 From: MarkoM-dot <83985775+MarkoM-dot@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:34:05 +0100 Subject: [PATCH 2/3] fix(tests): test for membership should be not in --- rest_framework/decorators.py | 2 +- tests/test_throttling.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 3b572c09ef..6194817563 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -36,7 +36,7 @@ def decorator(func): # WrappedAPIView.__doc__ = func.doc <--- Not possible to do this # api_view applied without (method_names) - assert not(isinstance(http_method_names, types.FunctionType)), \ + assert not (isinstance(http_method_names, types.FunctionType)), \ '@api_view missing list of allowed HTTP methods' # api_view applied with eg. string instead of list of strings diff --git a/tests/test_throttling.py b/tests/test_throttling.py index d5a61232d9..be9decebc5 100644 --- a/tests/test_throttling.py +++ b/tests/test_throttling.py @@ -192,7 +192,7 @@ def ensure_response_header_contains_proper_throttle_field(self, view, expected_h if expect is not None: assert response['Retry-After'] == expect else: - assert not'Retry-After' in response + assert 'Retry-After' not in response def test_seconds_fields(self): """ From b6febd6fe955fe5c57884f5f93be7772d8ce3c4a Mon Sep 17 00:00:00 2001 From: MarkoM-dot <83985775+MarkoM-dot@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:02:22 +0100 Subject: [PATCH 3/3] fix(compat): remove attribute error --- rest_framework/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index e4293cebf1..7e80704e11 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -82,7 +82,7 @@ def apply_markdown(text): ) md_filter_add_syntax_highlight(md) return md.convert(text) -except (ImportError, AttributeError): +except ImportError: apply_markdown = None markdown = None