diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2ff985a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +charset = utf-8 +max_line_length = 88 + +[*.{css,html,js,json,jsx,scss,ts,tsx,yaml,yml}] +indent_size = 2 diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..1d9c507 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Report a bug in Flask-DebugToolbar (not other projects which depend on Flask-DebugToolbar) +--- + + + + + + + +Environment: + +- Python version: +- Flask-DebugToolbar version: +- Flask version: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..b4fd5a2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Questions on Discussions + url: https://github.com/pallets-eco/flask-debugtoolbar/discussions/ + about: Ask questions about your own code on the Discussions tab. + - name: Questions on Chat + url: https://discord.gg/pallets + about: Ask questions about your own code on our Discord chat. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..3054225 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,15 @@ +--- +name: Feature request +about: Suggest a new feature for Flask-DebugToolbar +--- + + + + diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1f47f12 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + groups: + github-actions: + patterns: + - '*' + - package-ecosystem: pip + directory: /requirements/ + schedule: + interval: monthly + groups: + python-requirements: + patterns: + - '*' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..dbb67e3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,25 @@ + + + + + diff --git a/.github/workflows/lock.yaml b/.github/workflows/lock.yaml new file mode 100644 index 0000000..22228a1 --- /dev/null +++ b/.github/workflows/lock.yaml @@ -0,0 +1,23 @@ +name: Lock inactive closed issues +# Lock closed issues that have not received any further activity for two weeks. +# This does not close open issues, only humans may do that. It is easier to +# respond to new issues with fresh examples rather than continuing discussions +# on old issues. + +on: + schedule: + - cron: '0 0 * * *' +permissions: + issues: write + pull-requests: write +concurrency: + group: lock +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1 + with: + issue-inactive-days: 14 + pr-inactive-days: 14 + discussion-inactive-days: 14 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..d200f39 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,73 @@ +name: Publish +on: + push: + tags: + - '*' +jobs: + build: + runs-on: ubuntu-latest + outputs: + hash: ${{ steps.hash.outputs.hash }} + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: '3.x' + cache: pip + cache-dependency-path: requirements*/*.txt + - run: pip install -r requirements/build.txt + # Use the commit date instead of the current date during the build. + - run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + - run: python -m build + # Generate hashes used for provenance. + - name: generate hash + id: hash + run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + path: ./dist + provenance: + needs: [build] + permissions: + actions: read + id-token: write + contents: write + # Can't pin with hash due to how this workflow works. + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0 + with: + base64-subjects: ${{ needs.build.outputs.hash }} + create-release: + # Upload the sdist, wheels, and provenance to a GitHub release. They remain + # available as build artifacts for a while as well. + needs: [provenance] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + - name: create release + run: > + gh release create --draft --repo ${{ github.repository }} + ${{ github.ref_name }} + *.intoto.jsonl/* artifact/* + env: + GH_TOKEN: ${{ github.token }} + publish-pypi: + needs: [provenance] + # Wait for approval before attempting to upload to PyPI. This allows reviewing the + # files in the draft release. + environment: + name: publish + url: https://pypi.org/project/Flask-DebugToolbar/${{ github.ref_name }} + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + - uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 + with: + repository-url: https://test.pypi.org/legacy/ + packages-dir: artifact/ + - uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 + with: + packages-dir: artifact/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..b0065e7 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,39 @@ +name: Tests +on: + push: + branches: + - main + - '*.x' + paths-ignore: + - 'docs/**' + - '*.md' + - '*.rst' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + - '*.rst' +jobs: + tests: + name: ${{ matrix.name || matrix.python }} + runs-on: ${{ matrix.os || 'ubuntu-latest' }} + strategy: + fail-fast: false + matrix: + include: + - {python: '3.12'} + - {python: '3.11'} + - {python: '3.10'} + - {python: '3.9'} + - {python: '3.8'} + - {name: Minimal, python: '3.12', tox: minimal} + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: ${{ matrix.python }} + allow-prereleases: true + cache: pip + cache-dependency-path: requirements*/*.txt + - run: pip install tox + - run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index bfab79c..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Tests -on: - push: - branches: - - master - paths-ignore: - - 'docs/**' - - '*.rst' - pull_request: - paths-ignore: - - 'docs/**' - - '*.rst' -jobs: - tests: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - {name: Linux, python: '3.12', os: ubuntu-latest, tox: py312} - - {name: Windows, python: '3.12', os: windows-latest, tox: py312} - - {name: Mac, python: '3.12', os: macos-latest, tox: py312} - - {name: Minimal, python: '3.12', os: ubuntu-latest, tox: minimal} - - {name: '3.11', python: '3.11', os: ubuntu-latest, tox: py311} - - {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310} - - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39} - - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38} - - {name: Style, python: '3.10', os: ubuntu-latest, tox: stylecheck} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - name: update pip - run: | - pip install -U setuptools wheel - python -m pip install -U pip - - run: pip install tox - - run: tox -e ${{ matrix.tox }} diff --git a/.gitignore b/.gitignore index 68bc17f..62c1b88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,160 +1,10 @@ -# Byte-compiled / optimized / DLL files +.idea/ +.vscode/ +.venv*/ +venv*/ __pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports +.coverage* htmlcov/ .tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e875b7e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +ci: + autoupdate_schedule: monthly +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.2 + hooks: + - id: ruff + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-merge-conflict + exclude: "(codemirror|jquery)" + - id: debug-statements + exclude: "(codemirror|jquery)" + - id: fix-byte-order-marker + exclude: "(codemirror|jquery)" + - id: trailing-whitespace + exclude: "(codemirror|jquery)" + - id: end-of-file-fixer + exclude: "(codemirror|jquery)" diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0f81a3a..865c685 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,37 +1,13 @@ -# Read the Docs configuration file for Sphinx projects -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required version: 2 - -# Set the OS, Python version and other tools you might need build: - os: ubuntu-lts-latest + os: ubuntu-22.04 tools: - python: "latest" - # You can also specify other tool versions: - # nodejs: "20" - # rust: "1.70" - # golang: "1.20" - -# Build documentation in the "docs/" directory with Sphinx -sphinx: - configuration: docs/conf.py - # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs - # builder: "dirhtml" - # Fail on all warnings to avoid broken references - fail_on_warning: true - -# Optionally build your docs in additional formats such as PDF and ePub -# formats: -# - pdf -# - epub - -# Optional but recommended, declare the Python requirements required -# to build your documentation -# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html + python: '3.12' python: install: - - path: . - extra_requirements: - - docs + - requirements: requirements/docs.txt + - method: pip + path: . +sphinx: + builder: dirhtml + fail_on_warning: true diff --git a/LICENSE b/LICENSE.txt similarity index 54% rename from LICENSE rename to LICENSE.txt index 221d733..c76f903 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,24 +1,21 @@ -Copyright (c) Rob Hudson and individual contributors. -All rights reserved. +Copyright 2011 Pallets Community Ecosystem Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Django nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 9504683..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include LICENSE -recursive-include src/flask_debugtoolbar/templates *.html -recursive-include src/flask_debugtoolbar/static * diff --git a/README.md b/README.md new file mode 100644 index 0000000..c245a9f --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Flask-DebugToolbar + +A [Flask][] extension that injects debugging information into rendered HTML +pages. Presented as a sidebar with configurable panels of information. + +This is a port of the excellent [django-debug-toolbar] `_. + + +## Pallets Community Ecosystem + +> [!IMPORTANT]\ +> This project is part of the Pallets Community Ecosystem. Pallets is the open +> source organization that maintains Flask; Pallets-Eco enables community +> maintenance of related projects. If you are interested in helping maintain +> this project, please reach out on [the Pallets Discord server][discord]. + +[discord]: https://discord.gg/pallets + + +## Example + +Setting up the debug toolbar is simple: + +```python +from flask import Flask +from flask_debugtoolbar import DebugToolbarExtension + +app = Flask(__name__) +app.config["SECRET_KEY"] = "" + +toolbar = DebugToolbarExtension(app) +``` + +The toolbar will automatically be injected into Jinja templates when debug +mode is enabled. + +``` +$ flask -A my_app run --debug +``` + +![](https://raw.githubusercontent.com/pallets-eco/flask-debugtoolbar/main/docs/_static/screenshot-request-vars-panel.png) diff --git a/README.rst b/README.rst deleted file mode 100644 index 8cdec78..0000000 --- a/README.rst +++ /dev/null @@ -1,43 +0,0 @@ -Flask Debug-toolbar -=================== - -This is a port of the excellent `django-debug-toolbar `_ -for Flask applications. - -.. image:: https://github.com/pallets-eco/flask-debugtoolbar/actions/workflows/tests.yml/badge.svg - :target: https://github.com/pallets-eco/flask-debugtoolbar/actions - - -Installation ------------- - -Installing is simple with pip:: - - $ pip install flask-debugtoolbar - - -Usage ------ - -Setting up the debug toolbar is simple:: - - from flask import Flask - from flask_debugtoolbar import DebugToolbarExtension - - app = Flask(__name__) - - # the toolbar is only enabled in debug mode: - app.debug = True - - # set a 'SECRET_KEY' to enable the Flask session cookies - app.config['SECRET_KEY'] = '' - - toolbar = DebugToolbarExtension(app) - - -The toolbar will automatically be injected into Jinja templates when debug mode is on. -In production, setting ``app.debug = False`` will disable the toolbar. - -See the `documentation`_ for more information. - -.. _documentation: https://flask-debugtoolbar.readthedocs.io/ diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index d7becbf..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,157 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = _build - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: _themes - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Flask-DebugToolbar.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Flask-DebugToolbar.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/Flask-DebugToolbar" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Flask-DebugToolbar" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -_themes: - git clone git://github.com/Pylons/pylons_sphinx_theme.git _themes - cd ..; git submodule update --init; cd docs \ No newline at end of file diff --git a/docs/_static/.gitignore b/docs/_static/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/docs/_templates/.gitignore b/docs/_templates/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/docs/_themes b/docs/_themes deleted file mode 160000 index 1cc4468..0000000 --- a/docs/_themes +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1cc44686f0f9dad27cce2c9d16cf42f97bc87dbd diff --git a/docs/conf.py b/docs/conf.py index 66d1c50..ca04180 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,260 +1,39 @@ -# -*- coding: utf-8 -*- -# -# Flask-DebugToolbar documentation build configuration file, created by -# sphinx-quickstart on Wed Feb 15 18:08:39 2012. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. +import importlib.metadata -import datetime -import os -import pkg_resources -import sys -import time +# Project -------------------------------------------------------------- -import flask_debugtoolbar - - -BUILD_DATE = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- +project = "Flask-DebugToolbar" +version = release = importlib.metadata.version("flask-debugtoolbar").partition(".dev")[ + 0 +] -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# General -------------------------------------------------------------- -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +default_role = "code" extensions = [ - 'sphinx.ext.viewcode', - 'sphinx.ext.intersphinx', - 'pallets_sphinx_themes', + "sphinx.ext.autodoc", + "sphinx.ext.extlinks", + "sphinx.ext.intersphinx", + "sphinxcontrib.log_cabinet", + "pallets_sphinx_themes", ] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Flask-DebugToolbar' -copyright = u'2012-{0}'.format(BUILD_DATE.year) - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = flask_debugtoolbar.__version__ -# The short X.Y version. -version = '.'.join(release.split('.')[:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - -intersphinx_mapping = { - 'flasksqlalchemy': ('https://flask-sqlalchemy.palletsprojects.com/', None) +autodoc_member_order = "bysource" +autodoc_typehints = "description" +autodoc_preserve_defaults = True +extlinks = { + "issue": ("https://github.com/pallets-eco/flask-debugtoolbar/issues/%s", "#%s"), + "pr": ("https://github.com/pallets-eco/flask-debugtoolbar/pull/%s", "#%s"), } - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'flask' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -sys.path.append(os.path.abspath('_themes')) -html_theme_path = ['_themes'] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'Flask-DebugToolbardoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', +intersphinx_mapping = { + "python": ("https://docs.python.org/3/", None), + "flasksqlalchemy": ("https://flask-sqlalchemy.palletsprojects.com", None), } -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'Flask-DebugToolbar.tex', u'Flask-DebugToolbar Documentation', - u'Matt Good', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'flask-debugtoolbar', u'Flask-DebugToolbar Documentation', - [u'Matt Good'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'Flask-DebugToolbar', u'Flask-DebugToolbar Documentation', - u'Matt Good', 'Flask-DebugToolbar', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True +# HTML ----------------------------------------------------------------- -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +html_theme = "flask" +html_static_path = ["_static"] +html_copy_source = False +html_show_copyright = False +html_use_index = False +html_domain_indices = False diff --git a/docs/index.rst b/docs/index.rst index fe29617..cc3a40c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -73,7 +73,8 @@ Panels .. toctree:: - panels + panels + license Contributing ------------ @@ -88,11 +89,3 @@ This was based on the original `django-debug-toolbar`_. Thanks to `Michael van T .. _django-debug-toolbar: https://github.com/jazzband/django-debug-toolbar .. _Michael van Tellingen: https://github.com/mvantellingen .. _individual contributors: https://github.com/pallets-eco/flask-debugtoolbar/graphs/contributors - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docs/license.rst b/docs/license.rst new file mode 100644 index 0000000..2a445f9 --- /dev/null +++ b/docs/license.rst @@ -0,0 +1,5 @@ +BSD-3-Clause License +==================== + +.. literalinclude:: ../LICENSE.txt + :language: text diff --git a/example/app.py b/example/app.py index cd35b9e..b94e1bc 100644 --- a/example/app.py +++ b/example/app.py @@ -1,21 +1,24 @@ # Run using: `FLASK_DEBUG=True flask run` -from flask import Flask, render_template, redirect, url_for +from flask import Flask +from flask import redirect +from flask import render_template +from flask import url_for from flask_sqlalchemy import SQLAlchemy -from flask_debugtoolbar import DebugToolbarExtension +from flask_debugtoolbar import DebugToolbarExtension app = Flask(__name__) -app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True -#app.config['DEBUG_TB_PANELS'] = ( +app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = True +# app.config['DEBUG_TB_PANELS'] = ( # 'flask_debugtoolbar.panels.headers.HeaderDebugPanel', # 'flask_debugtoolbar.panels.logger.LoggingPanel', # 'flask_debugtoolbar.panels.timer.TimerDebugPanel', -#) -#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' ) -app.config['SECRET_KEY'] = 'asd' -app.config['SQLALCHEMY_RECORD_QUERIES'] = True -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' +# ) +# app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' ) +app.config["SECRET_KEY"] = "asd" +app.config["SQLALCHEMY_RECORD_QUERIES"] = True +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/test.db" # This is no longer needed for Flask-SQLAlchemy 3.0+, if you're using 2.X you'll want to define this: # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False @@ -24,21 +27,21 @@ class ExampleModel(db.Model): - __tablename__ = 'examples' + __tablename__ = "examples" value = db.Column(db.String(100), primary_key=True) -@app.route('/') +@app.route("/") def index(): app.logger.info("Hello there") ExampleModel.query.get(1) - return render_template('index.html') + return render_template("index.html") -@app.route('/redirect') +@app.route("/redirect") def redirect_example(): - response = redirect(url_for('index')) - response.set_cookie('test_cookie', '1') + response = redirect(url_for("index")) + response.set_cookie("test_cookie", "1") return response diff --git a/pyproject.toml b/pyproject.toml index 374b58c..9adbe54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,77 @@ +[project] +name = "Flask-DebugToolbar" +version = "0.15.1" +description = "A toolbar overlay for debugging Flask applications." +readme = "README.md" +license = { file = "LICENSE.txt" } +author = [{ name = "Michael van Tellingen" }] +maintainers = [{ name = "Pallets Ecosystem", email = "contact@palletsprojects.com" }] +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: Flask", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", +] +requires-python = ">=3.8" +dependencies = [ + "flask>=2.3.0", +] + +[project.urls] +Documentation = "https://flask-debugtoolbar.readthedocs.io" +Changes = "https://github.com/pallets-eco/flask-debugtoolbar/releases/" +Source = "https://github.com/pallets-eco/flask-debugtoolbar/" +Chat = "https://discord.gg/pallets" + [build-system] -requires = [ - "setuptools>=42", - "wheel" +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.module] +name = "flask_debugtoolbar" + +[tool.pytest.ini_options] +testpaths = ["tests"] +filterwarnings = [ + "error", +] + +[tool.coverage.run] +branch = true +source = ["flask_debugtoolbar", "tests"] + +[tool.coverage.paths] +source = ["src", "*/site-packages"] + +[tool.mypy] +python_version = "3.8" +files = ["src/flask_debugtoolbar", "tests"] +show_error_codes = true +pretty = true +strict = true + +[tool.pyright] +pythonVersion = "3.8" +include = ["src/flask_debugtoolbar", "tests"] +typeCheckingMode = "basic" + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.lint] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning ] -build-backend = "setuptools.build_meta" +ignore-init-module-imports = true + +[tool.ruff.lint.isort] +force-single-line = true +order-by-type = false diff --git a/requirements/build.in b/requirements/build.in new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/requirements/build.in @@ -0,0 +1 @@ +build diff --git a/requirements/build.txt b/requirements/build.txt new file mode 100644 index 0000000..0416fc7 --- /dev/null +++ b/requirements/build.txt @@ -0,0 +1,18 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile build.in +# +build==1.2.1 + # via -r build.in +importlib-metadata==7.1.0 + # via build +packaging==24.0 + # via build +pyproject-hooks==1.1.0 + # via build +tomli==2.0.1 + # via build +zipp==3.18.1 + # via importlib-metadata diff --git a/requirements/dev.in b/requirements/dev.in new file mode 100644 index 0000000..1efde82 --- /dev/null +++ b/requirements/dev.in @@ -0,0 +1,5 @@ +-r docs.txt +-r tests.txt +-r typing.txt +pre-commit +tox diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..a46d9e8 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,229 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile dev.in +# +alabaster==0.7.13 + # via + # -r docs.txt + # sphinx +babel==2.14.0 + # via + # -r docs.txt + # sphinx +blinker==1.8.1 + # via + # -r tests.txt + # flask +cachetools==5.3.3 + # via tox +certifi==2024.2.2 + # via + # -r docs.txt + # requests +cfgv==3.4.0 + # via pre-commit +chardet==5.2.0 + # via tox +charset-normalizer==3.3.2 + # via + # -r docs.txt + # requests +click==8.1.7 + # via + # -r tests.txt + # flask +colorama==0.4.6 + # via tox +distlib==0.3.8 + # via virtualenv +docutils==0.20.1 + # via + # -r docs.txt + # sphinx +exceptiongroup==1.2.1 + # via + # -r tests.txt + # -r typing.txt + # pytest +filelock==3.14.0 + # via + # tox + # virtualenv +flask==3.0.3 + # via + # -r tests.txt + # flask-sqlalchemy +flask-sqlalchemy==3.1.1 + # via -r tests.txt +identify==2.5.36 + # via pre-commit +idna==3.7 + # via + # -r docs.txt + # requests +imagesize==1.4.1 + # via + # -r docs.txt + # sphinx +importlib-metadata==7.1.0 + # via + # -r docs.txt + # -r tests.txt + # flask + # sphinx +iniconfig==2.0.0 + # via + # -r tests.txt + # -r typing.txt + # pytest +itsdangerous==2.2.0 + # via + # -r tests.txt + # flask +jinja2==3.1.3 + # via + # -r docs.txt + # -r tests.txt + # flask + # sphinx +markupsafe==2.1.5 + # via + # -r docs.txt + # -r tests.txt + # jinja2 + # werkzeug +mypy==1.10.0 + # via -r typing.txt +mypy-extensions==1.0.0 + # via + # -r typing.txt + # mypy +nodeenv==1.8.0 + # via + # -r typing.txt + # pre-commit + # pyright +packaging==24.0 + # via + # -r docs.txt + # -r tests.txt + # -r typing.txt + # pallets-sphinx-themes + # pyproject-api + # pytest + # sphinx + # tox +pallets-sphinx-themes==2.1.3 + # via -r docs.txt +platformdirs==4.2.1 + # via + # tox + # virtualenv +pluggy==1.5.0 + # via + # -r tests.txt + # -r typing.txt + # pytest + # tox +pre-commit==3.5.0 + # via -r dev.in +pygments==2.17.2 + # via + # -r docs.txt + # -r tests.txt + # sphinx +pyproject-api==1.6.1 + # via tox +pyright==1.1.360 + # via -r typing.txt +pytest==8.2.0 + # via + # -r tests.txt + # -r typing.txt +pytz==2024.1 + # via + # -r docs.txt + # babel +pyyaml==6.0.1 + # via pre-commit +requests==2.31.0 + # via + # -r docs.txt + # sphinx +snowballstemmer==2.2.0 + # via + # -r docs.txt + # sphinx +sphinx==7.1.2 + # via + # -r docs.txt + # pallets-sphinx-themes + # sphinxcontrib-log-cabinet +sphinxcontrib-applehelp==1.0.4 + # via + # -r docs.txt + # sphinx +sphinxcontrib-devhelp==1.0.2 + # via + # -r docs.txt + # sphinx +sphinxcontrib-htmlhelp==2.0.1 + # via + # -r docs.txt + # sphinx +sphinxcontrib-jsmath==1.0.1 + # via + # -r docs.txt + # sphinx +sphinxcontrib-log-cabinet==1.0.1 + # via -r docs.txt +sphinxcontrib-qthelp==1.0.3 + # via + # -r docs.txt + # sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via + # -r docs.txt + # sphinx +sqlalchemy==2.0.29 + # via + # -r tests.txt + # flask-sqlalchemy +tomli==2.0.1 + # via + # -r tests.txt + # -r typing.txt + # mypy + # pyproject-api + # pytest + # tox +tox==4.15.0 + # via -r dev.in +typing-extensions==4.11.0 + # via + # -r tests.txt + # -r typing.txt + # mypy + # sqlalchemy +urllib3==2.2.1 + # via + # -r docs.txt + # requests +virtualenv==20.26.1 + # via + # pre-commit + # tox +werkzeug==3.0.2 + # via + # -r tests.txt + # flask +zipp==3.18.1 + # via + # -r docs.txt + # -r tests.txt + # importlib-metadata + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/requirements/docs.in b/requirements/docs.in new file mode 100644 index 0000000..ba3fd77 --- /dev/null +++ b/requirements/docs.in @@ -0,0 +1,3 @@ +pallets-sphinx-themes +sphinx +sphinxcontrib-log-cabinet diff --git a/requirements/docs.txt b/requirements/docs.txt new file mode 100644 index 0000000..ce0440b --- /dev/null +++ b/requirements/docs.txt @@ -0,0 +1,63 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile docs.in +# +alabaster==0.7.13 + # via sphinx +babel==2.14.0 + # via sphinx +certifi==2024.2.2 + # via requests +charset-normalizer==3.3.2 + # via requests +docutils==0.20.1 + # via sphinx +idna==3.7 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==7.1.0 + # via sphinx +jinja2==3.1.3 + # via sphinx +markupsafe==2.1.5 + # via jinja2 +packaging==24.0 + # via + # pallets-sphinx-themes + # sphinx +pallets-sphinx-themes==2.1.3 + # via -r docs.in +pygments==2.17.2 + # via sphinx +pytz==2024.1 + # via babel +requests==2.31.0 + # via sphinx +snowballstemmer==2.2.0 + # via sphinx +sphinx==7.1.2 + # via + # -r docs.in + # pallets-sphinx-themes + # sphinxcontrib-log-cabinet +sphinxcontrib-applehelp==1.0.4 + # via sphinx +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==2.0.1 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-log-cabinet==1.0.1 + # via -r docs.in +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via sphinx +urllib3==2.2.1 + # via requests +zipp==3.18.1 + # via importlib-metadata diff --git a/requirements/tests.in b/requirements/tests.in new file mode 100644 index 0000000..1850600 --- /dev/null +++ b/requirements/tests.in @@ -0,0 +1,3 @@ +pytest +flask-sqlalchemy +pygments diff --git a/requirements/tests.txt b/requirements/tests.txt new file mode 100644 index 0000000..5715774 --- /dev/null +++ b/requirements/tests.txt @@ -0,0 +1,46 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile tests.in +# +blinker==1.8.1 + # via flask +click==8.1.7 + # via flask +exceptiongroup==1.2.1 + # via pytest +flask==3.0.3 + # via flask-sqlalchemy +flask-sqlalchemy==3.1.1 + # via -r tests.in +importlib-metadata==7.1.0 + # via flask +iniconfig==2.0.0 + # via pytest +itsdangerous==2.2.0 + # via flask +jinja2==3.1.3 + # via flask +markupsafe==2.1.5 + # via + # jinja2 + # werkzeug +packaging==24.0 + # via pytest +pluggy==1.5.0 + # via pytest +pygments==2.17.2 + # via -r tests.in +pytest==8.2.0 + # via -r tests.in +sqlalchemy==2.0.29 + # via flask-sqlalchemy +tomli==2.0.1 + # via pytest +typing-extensions==4.11.0 + # via sqlalchemy +werkzeug==3.0.2 + # via flask +zipp==3.18.1 + # via importlib-metadata diff --git a/requirements/typing.in b/requirements/typing.in new file mode 100644 index 0000000..8be59c5 --- /dev/null +++ b/requirements/typing.in @@ -0,0 +1,3 @@ +mypy +pyright +pytest diff --git a/requirements/typing.txt b/requirements/typing.txt new file mode 100644 index 0000000..3514478 --- /dev/null +++ b/requirements/typing.txt @@ -0,0 +1,33 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile typing.in +# +exceptiongroup==1.2.1 + # via pytest +iniconfig==2.0.0 + # via pytest +mypy==1.10.0 + # via -r typing.in +mypy-extensions==1.0.0 + # via mypy +nodeenv==1.8.0 + # via pyright +packaging==24.0 + # via pytest +pluggy==1.5.0 + # via pytest +pyright==1.1.360 + # via -r typing.in +pytest==8.2.0 + # via -r typing.in +tomli==2.0.1 + # via + # mypy + # pytest +typing-extensions==4.11.0 + # via mypy + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0143eb7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,36 +0,0 @@ -[metadata] -name = Flask-DebugToolbar -version = 0.15.1 -author = Michael van Tellingen -author_email = michaelvantellingen@gmail.com -maintainer = Matt Good -maintainer_email = matt@matt-good.net -description = A toolbar overlay for debugging Flask applications. -long_description = file: README.rst -long_description_content_type = text/x-rst -keywords = flask, debug, toolbar -url = https://github.com/pallets-eco/flask-debugtoolbar -project_urls = - Changelog = https://github.com/pallets-eco/flask-debugtoolbar/releases - Documentation = https://flask-debugtoolbar.readthedocs.io/ -classifiers = - Development Status :: 4 - Beta - Environment :: Web Environment - Framework :: Flask - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python - Topic :: Internet :: WWW/HTTP :: Dynamic Content - Topic :: Software Development :: Libraries :: Python Modules - -[options] -package_dir = - = src - -packages = find: -include_package_data = True -python_requires = >=3.8 - -[options.packages.find] -where = src diff --git a/setup.py b/setup.py deleted file mode 100644 index 28872bc..0000000 --- a/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -from setuptools import setup - -# Metadata goes in setup.cfg. These are here for GitHub's dependency graph. -setup( - name="Flask-DebugToolbar", - install_requires=[ - 'Flask>=2.3.0', - 'itsdangerous', - 'werkzeug', - 'MarkupSafe', - 'packaging', - ], - extras_require={ - "docs": [ - 'Sphinx>=1.2.2', - 'Pallets-Sphinx-Themes', - ], - } -) diff --git a/test/basic_app.py b/tests/basic_app.py similarity index 100% rename from test/basic_app.py rename to tests/basic_app.py diff --git a/test/conftest.py b/tests/conftest.py similarity index 100% rename from test/conftest.py rename to tests/conftest.py diff --git a/test/templates/basic_app.html b/tests/templates/basic_app.html similarity index 100% rename from test/templates/basic_app.html rename to tests/templates/basic_app.html diff --git a/test/test_toolbar.py b/tests/test_toolbar.py similarity index 100% rename from test/test_toolbar.py rename to tests/test_toolbar.py diff --git a/test/test_utils.py b/tests/test_utils.py similarity index 100% rename from test/test_utils.py rename to tests/test_utils.py diff --git a/tox.ini b/tox.ini index 42da9b5..b05c86d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,31 +1,52 @@ [tox] envlist = py3{12,11,10,9,8} - stylecheck minimal -skip_missing_interpreters = True + docs +skip_missing_interpreters = true [testenv] -deps = - pytest - Flask-SQLAlchemy - Pygments -commands = - pytest +package = wheel +wheel_build_env = .pkg +constrain_package_deps = true +use_frozen_constraints = true +deps = -r requirements/tests.txt +commands = pytest -v --tb=short --basetemp={envtmpdir} {posargs} [testenv:minimal] deps = - . -commands = - python -c "from flask_debugtoolbar import DebugToolbarExtension" +commands = python -c "from flask_debugtoolbar import DebugToolbarExtension" -[testenv:stylecheck] -deps = - pycodestyle +[testenv:style] +deps = pre-commit +skip_install = true +commands = pre-commit run --all-files + +[testenv:typing] +deps = -r requirements/typing.txt commands = - # E731: do not assign a lambda expression, use a def - # W504: line break after binary operator - pycodestyle src/flask_debugtoolbar test --ignore=E731,W504 + mypy + pyright + pyright --verifytypes flask_debugtoolbar --ignoreexternal + +[testenv:docs] +deps = -r requirements/docs.txt +commands = sphinx-build -E -W -b dirhtml docs docs/_build/dirhtml -[pycodestyle] -max-line-length = 100 +[testenv:update-pre_commit] +labels = update +deps = pre-commit +skip_install = true +commands = pre-commit autoupdate -j4 + +[testenv:update-requirements] +labels = update +deps = pip-tools +skip_install = true +change_dir = requirements +commands = + pip-compile build.in -q {posargs:-U} + pip-compile docs.in -q {posargs:-U} + pip-compile tests.in -q {posargs:-U} + pip-compile typing.in -q {posargs:-U} + pip-compile dev.in -q {posargs:-U}