From e7cba42ac6dc1b5e4fc1f6bd1cebd85934606479 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 28 Jul 2021 19:44:14 +0200 Subject: [PATCH 1/4] Updated check for ensure_sync --- flask_jwt_extended/view_decorators.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flask_jwt_extended/view_decorators.py b/flask_jwt_extended/view_decorators.py index f3ba655e..9defc595 100644 --- a/flask_jwt_extended/view_decorators.py +++ b/flask_jwt_extended/view_decorators.py @@ -121,12 +121,12 @@ def decorator(*args, **kwargs): verify_jwt_in_request(optional, fresh, refresh, locations) # Compatibility with flask < 2.0 - try: + if hasattr(current_app, "ensure_sync") and callable( + getattr(current_app, "ensure_sync", None) + ): return current_app.ensure_sync(fn)(*args, **kwargs) - except AttributeError as e: # pragma: no cover - if str(e) != "'Flask' object has no attribute 'ensure_sync'": - raise - return fn(*args, **kwargs) + + return fn(*args, **kwargs) # pragma: no cover return decorator From 3ec25621345aaa696176d3ee6866964ef7dce2f7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 28 Jul 2021 19:44:31 +0200 Subject: [PATCH 2/4] Added flask 1.1.4 to seperate tox env --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a9b46292..a0d5f940 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py36,py37,py38,py39,pypy3,coverage,style,docs +envlist = py36,py37,py38,py39,pypy3,flask1,coverage,style,docs [testenv] commands = @@ -13,6 +13,7 @@ deps = pytest cryptography python-dateutil + flask1: flask == 1.1.4 [testenv:coverage] commands = From 95843437616a5ea2c3e26a87e64d816b97a81bb8 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 30 Jul 2021 21:05:00 +0200 Subject: [PATCH 3/4] Updated Github Actions unit test workflow --- .github/workflows/unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index b8f4734d..c6a2074f 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -21,4 +21,4 @@ jobs: - name: Install Dependencies run: pip install tox - name: Run Tox - run: tox -e py + run: tox From 57fb8806fde03b170307692b9305957e3b9c21d5 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 30 Jul 2021 21:19:31 +0200 Subject: [PATCH 4/4] Hacky way of making the unit tests work for Flask 1 --- .github/workflows/unit_tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index c6a2074f..338941ec 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -21,4 +21,6 @@ jobs: - name: Install Dependencies run: pip install tox - name: Run Tox - run: tox + run: tox -e py + - name: Run Tox Flask 1 + run: tox -e flask1