From 83a89d30831f9aff6ff051b9db610bbc0ebf50c3 Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Wed, 6 Dec 2023 17:22:06 -0800 Subject: [PATCH] Require Flask >= `2.2.0`, Python >= `3.7` Require Flask >= `2.2.0`. I'm comfortable going up to requiring `3.x`, but when I grep'd for places we use older Flask constructs, this was all I found. So for now no need to jump further. Flask `2.2.0` requires Python >= `3.7`, so also dropped older pythons. --- .github/workflows/tests.yml | 1 - setup.cfg | 2 +- setup.py | 2 +- src/flask_debugtoolbar/__init__.py | 15 ++------------- test/test_toolbar.py | 25 ------------------------- tox.ini | 3 +-- 6 files changed, 5 insertions(+), 43 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95d8091..b027b4b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,6 @@ jobs: - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39} - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38} - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37} - - {name: '3.6', python: '3.6', os: ubuntu-20.04, tox: py36} # ubuntu-latest doesn't support 3.6 - {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck} steps: - uses: actions/checkout@v4 diff --git a/setup.cfg b/setup.cfg index dabccbb..459188e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,7 @@ package_dir = packages = find: include_package_data = True -python_requires = >=2.7 +python_requires = >=3.7 [options.packages.find] where = src diff --git a/setup.py b/setup.py index 6bf3d8b..e8e8da8 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="Flask-DebugToolbar", install_requires=[ - 'Flask>=0.8', + 'Flask>=2.2.0', 'Blinker', 'itsdangerous', 'werkzeug', diff --git a/src/flask_debugtoolbar/__init__.py b/src/flask_debugtoolbar/__init__.py index 3b3a7b7..b249bf8 100644 --- a/src/flask_debugtoolbar/__init__.py +++ b/src/flask_debugtoolbar/__init__.py @@ -3,15 +3,8 @@ import warnings import flask -from packaging import version as version_builder from flask import Blueprint, current_app, request, g, send_from_directory, url_for - - -if version_builder.parse(flask.__version__) >= version_builder.parse("2.2.0"): - from flask.globals import request_ctx -else: - from flask.globals import _request_ctx_stack - +from flask.globals import request_ctx from jinja2 import __version__ as __jinja_version__ from jinja2 import Environment, PackageLoader @@ -132,11 +125,7 @@ def _default_config(self, app): def dispatch_request(self): """Modified version of Flask.dispatch_request to call process_view.""" - if version_builder.parse(flask.__version__) >= version_builder.parse("2.2.0"): - req = request_ctx.request - else: - req = _request_ctx_stack.top.request - + req = request_ctx.request app = current_app if req.routing_exception is not None: diff --git a/test/test_toolbar.py b/test/test_toolbar.py index fd04ddc..6ad24ac 100644 --- a/test/test_toolbar.py +++ b/test/test_toolbar.py @@ -1,7 +1,5 @@ import sys -import pytest - from flask_debugtoolbar import _printable @@ -16,26 +14,3 @@ def test_basic_app(): index = app.get('/') assert index.status_code == 200 assert b'
= (3,), - reason='test only applies to Python 2') -def test_printable_unicode(): - class UnicodeRepr(object): - def __repr__(self): - return u'\uffff' - - printable = _printable(UnicodeRepr()) - assert "raised UnicodeEncodeError: 'ascii' codec" in printable - - -@pytest.mark.skipif(sys.version_info >= (3,), - reason='test only applies to Python 2') -def test_printable_non_ascii(): - class NonAsciiRepr(object): - def __repr__(self): - return 'a\xffb' - - printable = u'%s' % _printable(NonAsciiRepr()) - # should replace \xff with the unicode ? character - assert printable == u'a\ufffdb' diff --git a/tox.ini b/tox.ini index 48be4c1..408ef98 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,6 @@ [tox] envlist = - py27 - py3{12,11,10,9,8,7,6} + py3{12,11,10,9,8,7} stylecheck skip_missing_interpreters = True