346 Commits

Author SHA1 Message Date
Jeff Widman
4225f7f4ad Bump to 0.15.1 (#254)
Bump to `0.15.1` release so that we can get this minor bugfix live:
* #253
0.15.1
2024-04-27 11:03:27 -07:00
Joel Burton
a63f64051b Fix prob w/using w/o SQLAlchemy (#253) 2024-04-25 14:47:07 -07:00
Mac Newbold
bf21647c4b Bump to 0.15.0 (#251) 0.15.0 2024-04-24 14:38:33 -06:00
Jeff Widman
818e5f2d62 Bump to 0.15.0
We've merged a number of deprecation fixes, let's get them live to our users via a new release.
2024-04-24 07:59:07 -07:00
Jeff Widman
c65c6b94e5 Add .readthedocs.yaml file (#246)
Add `.readthedocs.yaml` file.

This config file is now required by RTD in order to build the docs.
2024-04-24 14:46:37 +00:00
Jeff Widman
0ca1f6b241 Install custom Sphinx theme via extras_require (#250)
Previously the custom theme was vendored in via a `git` submodule...

Now this theme is available via a python package, so install it using `extras_require` instead.

This also unlocks letting other tooling such as ReadTheDocs install the custom theme without having to do custom git incantations.

I also removed the `index_logo` config as Sphinx warns that it's not a supported option by the theme. I grep'd the theme package, and it makes no mention of this option, besides we were leaving it blank already, so there's no point in having it.
2024-04-24 07:40:27 -07:00
Mac Newbold
48de4e4a3c Prevent LookupError when accessing debug_toolbars_var (#245) 2024-04-18 10:59:27 -06:00
Mac Newbold
b139c60a60 Merge branch 'master' into master 2024-04-18 10:58:04 -06:00
Marc Aymerich Gunern
05f23436ac Prevent LookupError when accessing debug_toolbars_var when toolbar is being disabled in the middle of a request 2024-04-18 12:16:43 +01:00
Jeff Widman
7012193220 Replace deprecated pkg_resources with stdlib (#239)
`pkg_resources` has been deprecated by `setuptools` for quite a while: https://setuptools.pypa.io/en/latest/pkg_resources.html

It's got some bugs/warts:

* https://github.com/pypa/setuptools/issues/2531
* https://discuss.python.org/t/will-setuptools-remove-pkg-resource-module-in-the-future/27182

So switch to using `importlib` functions which are part of the Python standard library as of `3.8`.

This is less error-prone, and also removes the need for `setuptools` to be installed in order for this panel to work.

I realize we technically still support `3.7`, but I thought it was fine to change this particular panel to require `3.8`, as `3.7` support is best effort given that it's now EOL'd by the core Python team.

I also removed the relative path location for specific libraries as it was simply blank for me on Python 3.12... I think showing the location of the site packages directory should suffice. If someone later wants to build this out further, they're more than welcome to.

Note that `importlib.metadata.distributions()` does have an outstanding issue that it reports a local editable install twice, but they plan to eventually fix that:
* https://github.com/pypa/setuptools/issues/4170
2024-04-13 13:54:46 +00:00
Jeff Widman
7f3defff7c Fix some jquery deprecation warnings (#242)
Ths is a follow-on PR to
https://github.com/pallets-eco/flask-debugtoolbar/pull/241 in order to fix the deprecation warnings:
* `bind()` replaced by `on()`
* `click(handler)` replaced by `on('click', handler)`

Three deprecation warnings remain, but they are caused by the `jquery.tablesorter.js` plugin, so need to be handled upstream:
* https://github.com/Mottie/tablesorter/issues/1787
* https://github.com/Mottie/tablesorter/pull/1786

Related:
* https://github.com/pallets-eco/flask-debugtoolbar/issues/166
2024-04-13 13:48:56 +00:00
Jeff Widman
969cce532d Bump jquery to 3.7.1 and jquery-migrate to 3.4.1 (#241)
Bump to the latest versions of `jquery` and `jquery-migrate`.

I popped open the browser console and I see five deprecation warnings, but 3 out of the 5 are triggered by `jquery.tablesorter.js` which we vendor, so nothing we can do there.

The other two we should address, but we can do so in a follow-on PR as they are merely deprecations at this point, not fatal errors.

So getting onto the `3.x` series, even with deprecation warnings, is a nice step forward.

Previously we shipped the minified version of `jquery`, and we could
continue to do so, but given this is a dev tool and we still have
warnings we need to fix, I opted for the non-minified version for now.

Additionally, they offer a `slim` varient that is stripped down... we
could probably use that too, but I didn't take the time to investigate.

Fix: https://github.com/pallets-eco/flask-debugtoolbar/issues/166
2024-04-13 13:42:23 +00:00
Jeff Widman
c2804c4917 Bump jquery to 1.12.4 (#236)
This will allow us to migrate to the latest version of jquery 1.x series.

After we're on 1.9.x we can upgrade to the 3.x series.

I bumped this, and then checked the developer console while clicking
through the various panels offered in FDBT... Everything worked as
expected and I got zero warnings from `jquery-migrate`. So I think it's
safe to pull this in.

This is a pre-requesite to upgrading to the latest version of `jquery`,
as per their docs we have to first bump to `1.9+`, then bump the version
of `jquery-migrate`, then can bump to latest `jquery` version.

While I could do this in a single PR, I thought simpler to do it as a
series of PRs for easier reversion if we later run into problems.

Related:
* https://github.com/pallets-eco/flask-debugtoolbar/issues/166
2024-04-13 13:39:41 +00:00
Jeff Widman
56beb35c36 Update jquery.tablesorter.js plugin (#235)
Update to the latest `v2.31.3` version of this `jquery` plugin, which
unblocks upgrading to `jquery` >= `1.9.x`.

Using a fork because:

1. The original repo hasn't been updated in seven years: https://github.com/christianbach/tablesorter
2. The most recent committer to the original repo ☝️  now maintains the fork.
3. The fork was updated just a few months ago.
4. The fork supports the latest versions of `jquery`:
     > Works with jQuery 1.9+ (`$.browser.msie` was removed; needed in the original version)

As far as I can tell, no other changes are needed.

This is a straight copy/paste of the non-minized code from: https://github.com/Mottie/tablesorter

I used non-minimized for simplicity, since this is a dev-only tool, the
perf impacts of minimization don't really matter.

I tested this manually by:

```shell
$ cd flask-debugtoolbar/test
$ flask --app basic_app run --debug
```

Then loading `http://127.0.0.1:5000/` in a recent version of Chrome and
finding a FDBT panel that uses the sorter. In this case, the SQLAlchemy
panel. I visually compared behavior pre/past upgrade and it appeared
identical.

Related:
* https://github.com/pallets-eco/flask-debugtoolbar/issues/166
2024-04-13 06:37:37 -07:00
Jeff Widman
98bf17aa58 Fix trailing whitespace (#237)
I noticed some trailing whitespace has crept into these files. It wasn't caught by `pycodestyle` because that only checks Python files.

Ideally we'd add a linter that catches these, but I didn't want to take the time to configure one right now, I just want my editor to stop flagging these while I'm working on trying to upgrade `jquery` versions.

Long term, we'll probably want a meta-linter like `prettier` or whatever the newest kid on the block is.
2024-04-12 16:27:04 +00:00
Grey Li
716f05d953 Remove deprecated Flask version attribute (#243)
The `flask.__version__` attr is deprecated and will be removed in the Flask 3.1 version. This PR replaced this attr to `importlib.metadata.version`.

We could remove the use of `pkg_resources` when we drop the Python 3.7 support.
2024-04-12 09:20:53 -07:00
Jeff Widman
fb28aa9d61 Fix missing distutils error on Python 3.12 (#238)
Running on Python 3.12 I see:

```shell
[2024-04-11 11:01:12,915] WARNING in toolbar: Disabled flask_debugtoolbar.panels.versions.VersionDebugPanel due to ImportError: import_string() failed for 'flask_debugtoolbar.panels.versions.VersionDebugPanel'. Possible reasons are:

- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;

Debugged import:

- 'flask_debugtoolbar' found in '/Users/jeffwidman/Code/open-source/flask-debugtoolbar/src/flask_debugtoolbar/__init__.py'.
- 'flask_debugtoolbar.panels' found in '/Users/jeffwidman/Code/open-source/flask-debugtoolbar/src/flask_debugtoolbar/panels/__init__.py'.
- 'flask_debugtoolbar.panels.versions' not found.

Original exception:

ModuleNotFoundError: No module named 'distutils'
```

This is because Python 3.12 removed `distutils`.

Fix pulled from https://bugs.python.org/issue41282#msg393018.

This will not work on Python `3.6`, but we've already dropped support for that.

After the fix, the error is gone and the Versions panel re-appears.
2024-04-11 18:18:04 -07:00
Mac Newbold
efe447fb5f Fix SQLAlchemy recording warning for versions >= 3 (#233) 2024-03-20 09:28:47 -06:00
Jonty Wareing
9656a2cf33 Fix SQLAlchemy recording warning for versions >= 3
Since SQLAlchemy 3.0 `SQLALCHEMY_RECORD_QUERIES` is no longer
automatically enabled when Flask is running in debug or testing mode so
the debug toolbar warning will never be shown.

https://flask-sqlalchemy.palletsprojects.com/en/3.0.x/config/#flask_sqlalchemy.config.SQLALCHEMY_RECORD_QUERIES
2024-03-20 14:25:36 +00:00
Mac Newbold
9b63ad1837 Support applications using flask.copy_current_request_context (#231) 2024-01-17 09:40:50 -07:00
Marc Aymerich Gunern
765f22126e Handle cases when debug toolbar has not been installed 2024-01-11 18:06:28 +00:00
Marc Aymerich Gunern
d4a8cc963e Support applications using flask.copy_current_request_context 2024-01-09 13:50:02 +00:00
Mac Newbold
b7f5a725cd Add init_app() method to DebugPanel base class (#95) 2023-12-20 09:35:17 -07:00
Malthe Jørgensen
5bf5e093bb [Add] init_app()-method to DebugPanel base class
Adds a method `DebugPanel.init_app()` that gets called from
`DebugToolbar.init_app()`.

This allows DebugPanels to register their own routes, and do setup work
that should go across requests (as opposed to per-request setup) and
needs access to the Flask `app`-object.
2023-12-15 10:14:33 +01:00
Mac Newbold
719fe02df5 Add option to dump profiler stats (#204) 2023-12-13 10:49:10 -07:00
Dosenpfand
f18bcc708a Remove trailing whitespaces 2023-12-13 10:47:24 -07:00
Dosenpfand
95c2b86bcd Add profile dump stats option 2023-12-13 10:47:24 -07:00
Mac Newbold
b03a2e6fb3 Require Flask >= 2.2.0 (#224) 2023-12-11 11:27:45 -07:00
Jeff Widman
1c39a9ce47 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.
2023-12-11 11:25:52 -07:00
Mac Newbold
8c8b2bb35c Add minimal test without extra deps (#230) 2023-12-10 20:18:10 -07:00
Grey Li
a2e773124f Add minimal test without extra deps
To prevent issues like https://github.com/pallets-eco/flask-debugtoolbar/pull/225,
This PR add a minimal test that no extra deps are involved, it only install
the package, then try to import the extension class.

fixes #226
2023-12-10 12:54:29 +08:00
Jeff Widman
2f8ec9027b Bump to version 0.14.1 (#227) 0.14.1 2023-12-07 09:31:28 -08:00
Grey Li
ab9a41df6a Add the missing install requirement packaging (#225)
The `packaging` lib is not listed in the `install_requires` list.

https://github.com/greyli/flask-extension-status/actions/runs/7129071225/job/19412328108

```
Run python -c "from flask import Flask; app = Flask(__name__); from flask_debugtoolbar import DebugToolbarExtension; DebugToolbarExtension(app)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/flask_debugtoolbar/__init__.py", line 6, in <module>
    from packaging import version as version_builder
ModuleNotFoundError: No module named 'packaging'
Error: Process completed with exit code 1.
```
2023-12-07 08:32:29 -08:00
Jeff Widman
2b1e7d9907 Bump version to 0.14.0 (#223)
We need this to land before we can push a release...
0.14.0
2023-12-06 16:48:19 -08:00
Mac Newbold
d0360218fd Drop CHANGES.rst in favor of GitHub Releases (#198) 2023-11-21 08:26:28 -07:00
Mac Newbold
e9fd3072a9 Merge branch 'master' into switch-to-using-github-auto-generated-releases 2023-11-21 08:24:53 -07:00
Grey Li
1aedfb0e2e Use standard Python gitignore file (#220)
Created from https://github.com/github/gitignore/blob/main/Python.gitignore
2023-11-20 18:29:03 -08:00
Grey Li
e6ae9d0288 Fix the test for basic app (#221)
1. Update the test app

If I understand correctly, the debug toolbar will only be enabled if `app.debug` is `True`. So I added the `DEBUG=True` to the test app.

Related code: 2b8bf9cc44/src/flask_debugtoolbar/__init__.py (L114)

2. Update the `src/flask_debugtoolbar/__init__.py`

Fix the two if statements to prevent the following errors:

```
>       if 'gzip' in response.headers.get('Content-Encoding'):
E       TypeError: argument of type 'NoneType' is not iterable
```

Since the `response.headers.get('Content-Encoding')` could be None.

With this PR, all the tests will be passed. The failed style checker will be fixed in #219
2023-11-20 18:21:38 -08:00
Grey Li
62ce443f8b Fix lint issues and lint config (#219)
For the two ignored rules:

- E731: It's OK to use lambda
- W504: W503 and W504 are conflicts with each other, we need to disable one of them.
2023-11-20 10:59:24 -08:00
Grey Li
2b8bf9cc44 Remove the use of before_first_request (#218) 2023-11-17 22:12:44 +08:00
Grey Li
42d859534a Remove the use of before_first_request 2023-11-17 22:09:25 +08:00
Grey Li
f959951185 Fix tox and GitHub actions settings (#217)
* Remove the branch constraint for pull request triggering
* Use Python 3.12 for main tests
* Use `ubuntu-20.04` for Python 3.6 since it's been removed in `ubuntu-latest`
* Remove Python 2.7 since it's not supported by GitHub Actions anymore (https://github.com/actions/setup-python/issues/672)
* Add the missing `setup-python` step
* Merge the `pip install` commands
2023-11-16 14:41:30 -08:00
dadavec
e1c8704444 Remove deprecated charset property from process_response content crafting (#211)
The `Request.charset` property is deprecated since Werkzeug version 2.3. It was removed in Werkzeug 3.0. Request data must always be UTF-8.

https://werkzeug.palletsprojects.com/en/2.3.x/wrappers/#werkzeug.wrappers.Request.charset
2023-11-15 19:53:02 -08:00
Mac Newbold
8a4cfa5e3c No need to specify custom default value if key not found (#210) 2023-11-15 17:30:39 -07:00
Grey Li
51d105afad Set up GitHub actions to replace Travis (#215) 2023-11-16 02:10:00 +08:00
Grey Li
15192f19e0 Set up github actions 2023-11-15 22:28:43 +08:00
Jeff Widman
5712e57869 No need to specify custom default value if key not found
The `''` arg specifies a custom default value if the key isn't found. However, the default of `None` works fine for boolean testing:

```python
>>> 'gzip' in [None]
False
```

I missed this when I originally reviewed https://github.com/pallets-eco/flask-debugtoolbar/pull/154.
2023-10-13 13:39:35 +00:00
Hiromasa Ihara
9571d06df5 fix: drop response.charset because charset deprecated (#206)
I took a quick peek at upstream to see if this has any backwards-breaking issues whereby we'd need to check the `werkzeug` version, but from my reading it looks it should be fine most of the time.

Also, this was deprecated back in April's `2.3.0` release and then removed in the recent `3.0.0` release, so I suspect most of our userbase will have already migrated to those versions.

Given this lib is a dev-tooling library not typically used in production, I'm not too worried about ensuring we support the 0.01% case where someone is using an old version of `werkzeug` + a custom charset.

More context:
* https://github.com/pallets/werkzeug/issues/2602
* https://github.com/pallets/werkzeug/pull/2641
* https://github.com/pallets/werkzeug/pull/2768
2023-10-13 06:35:25 -07:00
Nick Janetakis
3b25e114e9 fix: use urllib.parse.quote_plus and drop werkzeug.urls.url_quote_plus (#207) 2023-10-06 18:19:51 -04:00
Hiromasa Ihara
f7ae3fd591 fix: use urllib.parse.quote_plus and drop werkzeug.urls.url_quote_plus 2023-10-01 16:03:15 +09:00