Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Flask >= 2.2.0 #224

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup(
name="Flask-DebugToolbar",
install_requires=[
'Flask>=0.8',
'Flask>=2.2.0',
'Blinker',
'itsdangerous',
'werkzeug',
Expand Down
15 changes: 2 additions & 13 deletions src/flask_debugtoolbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
25 changes: 0 additions & 25 deletions test/test_toolbar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sys

import pytest

from flask_debugtoolbar import _printable


Expand All @@ -16,26 +14,3 @@ def test_basic_app():
index = app.get('/')
assert index.status_code == 200
assert b'<div id="flDebug"' in index.data


@pytest.mark.skipif(sys.version_info >= (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'
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist =
py27
py3{12,11,10,9,8,7,6}
py3{12,11,10,9,8,7}
stylecheck
minimal
skip_missing_interpreters = True
Expand Down