Merge branch '2.0.x'

This commit is contained in:
David Lord 2022-02-09 07:37:43 -08:00
commit e37e87140e
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
23 changed files with 221 additions and 180 deletions

View file

@ -1,15 +1,5 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: "pip"
directory: "/requirements"
target-branch: "2.0.x"
versioning-strategy: "lockfile-only"
schedule:
interval: "monthly"
day: "monday"
time: "16:00"
timezone: "UTC"
open-pull-requests-limit: 99
- package-ecosystem: "github-actions" - package-ecosystem: "github-actions"
directory: "/" directory: "/"
schedule: schedule:

View file

@ -40,18 +40,12 @@ jobs:
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- name: update pip - name: update pip
run: | run: |
pip install -U wheel pip install -U wheel
pip install -U setuptools pip install -U setuptools
python -m pip install -U pip python -m pip install -U pip
- name: get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
- name: cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }}
- run: pip install tox - run: pip install tox
- run: tox -e ${{ matrix.tox }} - run: tox -e ${{ matrix.tox }}

View file

@ -8,14 +8,14 @@ repos:
- id: pyupgrade - id: pyupgrade
args: ["--py36-plus"] args: ["--py36-plus"]
- repo: https://github.com/asottile/reorder_python_imports - repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0 rev: v2.7.1
hooks: hooks:
- id: reorder-python-imports - id: reorder-python-imports
name: Reorder Python imports (src, tests) name: Reorder Python imports (src, tests)
files: "^(?!examples/)" files: "^(?!examples/)"
args: ["--application-directories", "src"] args: ["--application-directories", "src"]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.12b0 rev: 22.1.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
@ -25,6 +25,10 @@ repos:
additional_dependencies: additional_dependencies:
- flake8-bugbear - flake8-bugbear
- flake8-implicit-str-concat - flake8-implicit-str-concat
- repo: https://github.com/peterdemin/pip-compile-multi
rev: v2.4.3
hooks:
- id: pip-compile-multi-verify
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 rev: v4.1.0
hooks: hooks:

View file

@ -27,6 +27,13 @@ environment variable is used to specify how to load the application.
$ export FLASK_APP=hello $ export FLASK_APP=hello
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -156,6 +163,20 @@ reloader.
* Debugger is active! * Debugger is active!
* Debugger PIN: 223-456-919 * Debugger PIN: 223-456-919
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
* Serving Flask app "hello"
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with inotify reloader
* Debugger is active!
* Debugger PIN: 223-456-919
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -207,6 +228,17 @@ separated with ``:``, or ``;`` on Windows.
* Running on http://127.0.0.1:8000/ * Running on http://127.0.0.1:8000/
* Detected change in '/path/to/file1', reloading * Detected change in '/path/to/file1', reloading
.. group-tab:: Fish
.. code-block:: text
$ flask run --extra-files file1:dirA/file2:dirB/
# or
$ set -x FLASK_RUN_EXTRA_FILES file1 dirA/file2 dirB/
$ flask run
* Running on http://127.0.0.1:8000/
* Detected change in '/path/to/file1', reloading
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -287,6 +319,14 @@ command, instead of ``flask run --port 8000``:
$ flask run $ flask run
* Running on http://127.0.0.1:8000/ * Running on http://127.0.0.1:8000/
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_RUN_PORT 8000
$ flask run
* Running on http://127.0.0.1:8000/
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -334,6 +374,13 @@ configure as expected.
$ export FLASK_SKIP_DOTENV=1 $ export FLASK_SKIP_DOTENV=1
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_SKIP_DOTENV 1
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -364,6 +411,12 @@ script. Activating the virtualenv will set the variables.
$ export FLASK_APP=hello $ export FLASK_APP=hello
.. group-tab:: Fish
Fish, :file:`venv/bin/activate.fish`::
$ set -x FLASK_APP hello
.. group-tab:: CMD .. group-tab:: CMD
Windows CMD, :file:`venv\\Scripts\\activate.bat`:: Windows CMD, :file:`venv\\Scripts\\activate.bat`::

View file

@ -76,6 +76,13 @@ set :envvar:`FLASK_ENV`:
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -445,6 +452,14 @@ in the shell before starting the server:
$ flask run $ flask run
* Running on http://127.0.0.1:5000/ * Running on http://127.0.0.1:5000/
.. group-tab:: Fish
.. code-block:: text
$ set -x YOURAPPLICATION_SETTINGS /path/to/settings.cfg
$ flask run
* Running on http://127.0.0.1:5000/
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -517,6 +532,15 @@ Environment variables can be set in the shell before starting the server:
$ flask run $ flask run
* Running on http://127.0.0.1:5000/ * Running on http://127.0.0.1:5000/
.. group-tab:: Fish
.. code-block:: text
$ set -x SECRET_KEY "5f352379324c22463451387a0aec5d2f"
$ set -x MAIL_ENABLED false
$ flask run
* Running on http://127.0.0.1:5000/
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -53,6 +53,13 @@ enables the debugger and reloader.
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -106,6 +113,13 @@ When running from the command line:
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run --no-debugger --no-reload $ flask run --no-debugger --no-reload
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run --no-debugger --no-reload
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -98,6 +98,13 @@ To run such an application, you can use the :command:`flask` command:
$ export FLASK_APP=myapp $ export FLASK_APP=myapp
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP myapp
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -124,6 +131,13 @@ in ``myapp``. You can also pass arguments to the factory like this:
$ export FLASK_APP="myapp:create_app('dev')" $ export FLASK_APP="myapp:create_app('dev')"
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP "myapp:create_app('dev')"
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -67,6 +67,12 @@ that tells Flask where to find the application instance:
$ export FLASK_APP=yourapplication $ export FLASK_APP=yourapplication
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP yourapplication
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -91,6 +97,12 @@ development features like this:
$ export FLASK_ENV=development $ export FLASK_ENV=development
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -54,6 +54,14 @@ to tell your terminal the application to work with by exporting the
$ flask run $ flask run
* Running on http://127.0.0.1:5000/ * Running on http://127.0.0.1:5000/
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ flask run
* Running on http://127.0.0.1:5000/
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text
@ -166,6 +174,13 @@ variable to ``development`` before calling ``flask run``.
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_ENV development
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -173,18 +173,6 @@ invisibly to clicks on your page's elements. This is also known as
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
X-XSS-Protection
~~~~~~~~~~~~~~~~
The browser will try to prevent reflected XSS attacks by not loading the page
if the request contains something that looks like JavaScript and the response
contains the same data. ::
response.headers['X-XSS-Protection'] = '1; mode=block'
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
.. _security-cookie: .. _security-cookie:
Set-Cookie options Set-Cookie options

View file

@ -33,6 +33,14 @@ fully enable development mode.
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP hello
$ export FLASK_ENV=development
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -57,6 +57,13 @@ create the database in the instance folder.
$ export FLASK_APP=flaskr $ export FLASK_APP=flaskr
$ flask init-db $ flask init-db
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP flaskr
$ flask init-db
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -145,6 +145,14 @@ follow the tutorial.
$ export FLASK_ENV=development $ export FLASK_ENV=development
$ flask run $ flask run
.. group-tab:: Fish
.. code-block:: text
$ set -x FLASK_APP flaskr
$ set -x FLASK_ENV development
$ flask run
.. group-tab:: CMD .. group-tab:: CMD
.. code-block:: text .. code-block:: text

View file

@ -1,6 +1,6 @@
-r docs.in -r docs.in
-r tests.in -r tests.in
-r typing.in -r typing.in
pip-tools pip-compile-multi
pre-commit pre-commit
tox tox

View file

@ -1,156 +1,52 @@
# SHA1:54b5b77ec8c7a0064ffa93b2fd16cb0130ba177c
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/dev.in # pip-compile-multi
# #
alabaster==0.7.12 -r docs.txt
# via sphinx -r tests.txt
asgiref==3.4.1 -r typing.txt
# via -r requirements/tests.in
attrs==21.4.0
# via pytest
babel==2.9.1
# via sphinx
blinker==1.4
# via -r requirements/tests.in
certifi==2021.10.8
# via requests
cffi==1.15.0
# via cryptography
cfgv==3.3.1 cfgv==3.3.1
# via pre-commit # via pre-commit
charset-normalizer==2.0.10
# via requests
click==8.0.3 click==8.0.3
# via pip-tools # via
cryptography==36.0.1 # pip-compile-multi
# via -r requirements/typing.in # pip-tools
distlib==0.3.4 distlib==0.3.4
# via virtualenv # via virtualenv
docutils==0.16
# via
# sphinx
# sphinx-tabs
filelock==3.4.2 filelock==3.4.2
# via # via
# tox # tox
# virtualenv # virtualenv
greenlet==1.1.2 ; python_version < "3.11" greenlet==1.1.2 ; python_version < "3.11"
# via -r requirements/tests.in # via -r requirements/tests.in
identify==2.4.3 identify==2.4.8
# via pre-commit # via pre-commit
idna==3.3
# via requests
imagesize==1.3.0
# via sphinx
iniconfig==1.1.1
# via pytest
jinja2==3.0.3
# via sphinx
markupsafe==2.0.1
# via jinja2
mypy==0.931
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
nodeenv==1.6.0 nodeenv==1.6.0
# via pre-commit # via pre-commit
packaging==21.3
# via
# pallets-sphinx-themes
# pytest
# sphinx
# tox
pallets-sphinx-themes==2.0.2
# via -r requirements/docs.in
pep517==0.12.0 pep517==0.12.0
# via pip-tools # via pip-tools
pip-tools==6.4.0 pip-compile-multi==2.4.3
# via -r requirements/dev.in # via -r requirements/dev.in
pip-tools==6.5.1
# via pip-compile-multi
platformdirs==2.4.1 platformdirs==2.4.1
# via virtualenv # via virtualenv
pluggy==1.0.0 pre-commit==2.17.0
# via
# pytest
# tox
pre-commit==2.16.0
# via -r requirements/dev.in # via -r requirements/dev.in
py==1.11.0
# via
# pytest
# tox
pycparser==2.21
# via cffi
pygments==2.11.2
# via
# sphinx
# sphinx-tabs
pyparsing==3.0.6
# via packaging
pytest==6.2.5
# via -r requirements/tests.in
python-dotenv==0.19.2
# via -r requirements/tests.in
pytz==2021.3
# via babel
pyyaml==6.0 pyyaml==6.0
# via pre-commit # via pre-commit
requests==2.27.1
# via sphinx
six==1.16.0 six==1.16.0
# via # via
# tox # tox
# virtualenv # virtualenv
snowballstemmer==2.2.0 toposort==1.7
# via sphinx # via pip-compile-multi
sphinx==4.3.2
# via
# -r requirements/docs.in
# pallets-sphinx-themes
# sphinx-issues
# sphinx-tabs
# sphinxcontrib-log-cabinet
sphinx-issues==3.0.1
# via -r requirements/docs.in
sphinx-tabs==3.2.0
# via -r requirements/docs.in
sphinxcontrib-applehelp==1.0.2
# via sphinx
sphinxcontrib-devhelp==1.0.2
# via sphinx
sphinxcontrib-htmlhelp==2.0.0
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-log-cabinet==1.0.1
# via -r requirements/docs.in
sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
toml==0.10.2
# via
# pre-commit
# pytest
# tox
tomli==2.0.0
# via
# mypy
# pep517
tox==3.24.5 tox==3.24.5
# via -r requirements/dev.in # via -r requirements/dev.in
types-contextvars==2.4.1 virtualenv==20.13.1
# via -r requirements/typing.in
types-dataclasses==0.6.4
# via -r requirements/typing.in
types-setuptools==57.4.7
# via -r requirements/typing.in
typing-extensions==4.0.1
# via mypy
urllib3==1.26.8
# via requests
virtualenv==20.13.0
# via # via
# pre-commit # pre-commit
# tox # tox

View file

@ -1,8 +1,9 @@
# SHA1:34fd4ca6516e97c7348e6facdd9c4ebb68209d1c
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/docs.in # pip-compile-multi
# #
alabaster==0.7.12 alabaster==0.7.12
# via sphinx # via sphinx
@ -10,7 +11,7 @@ babel==2.9.1
# via sphinx # via sphinx
certifi==2021.10.8 certifi==2021.10.8
# via requests # via requests
charset-normalizer==2.0.10 charset-normalizer==2.0.11
# via requests # via requests
docutils==0.16 docutils==0.16
# via # via
@ -34,7 +35,7 @@ pygments==2.11.2
# via # via
# sphinx # sphinx
# sphinx-tabs # sphinx-tabs
pyparsing==3.0.6 pyparsing==3.0.7
# via packaging # via packaging
pytz==2021.3 pytz==2021.3
# via babel # via babel
@ -42,7 +43,7 @@ requests==2.27.1
# via sphinx # via sphinx
snowballstemmer==2.2.0 snowballstemmer==2.2.0
# via sphinx # via sphinx
sphinx==4.3.2 sphinx==4.4.0
# via # via
# -r requirements/docs.in # -r requirements/docs.in
# pallets-sphinx-themes # pallets-sphinx-themes
@ -69,6 +70,3 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx # via sphinx
urllib3==1.26.8 urllib3==1.26.8
# via requests # via requests
# The following packages are considered to be unsafe in a requirements file:
# setuptools

View file

@ -1,8 +1,9 @@
# SHA1:692b640e7f835e536628f76de0afff1296524122
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/tests-pallets-dev.in # pip-compile-multi
# #
click @ https://github.com/pallets/click/archive/refs/heads/main.tar.gz click @ https://github.com/pallets/click/archive/refs/heads/main.tar.gz
# via -r requirements/tests-pallets-dev.in # via -r requirements/tests-pallets-dev.in

View file

@ -1,8 +1,9 @@
# SHA1:4de7d9e6254a945fd97ec10880dd23b6cd43b70d
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/tests-pallets-min.in # pip-compile-multi
# #
click==8.0.0 click==8.0.0
# via -r requirements/tests-pallets-min.in # via -r requirements/tests-pallets-min.in

View file

@ -1,5 +1,5 @@
pytest pytest<7
asgiref asgiref<3.5
blinker blinker
greenlet ; python_version < "3.11" greenlet ; python_version < "3.11"
python-dotenv python-dotenv

View file

@ -1,8 +1,9 @@
# SHA1:39a475af80093ba5deaee28d9ac0851afb91b6a9
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/tests.in # pip-compile-multi
# #
asgiref==3.4.1 asgiref==3.4.1
# via -r requirements/tests.in # via -r requirements/tests.in
@ -20,7 +21,7 @@ pluggy==1.0.0
# via pytest # via pytest
py==1.11.0 py==1.11.0
# via pytest # via pytest
pyparsing==3.0.6 pyparsing==3.0.7
# via packaging # via packaging
pytest==6.2.5 pytest==6.2.5
# via -r requirements/tests.in # via -r requirements/tests.in

View file

@ -1,8 +1,9 @@
# SHA1:7cc3f64d4e78db89d81680ac81503d5ac35d31a9
# #
# This file is autogenerated by pip-compile with python 3.10 # This file is autogenerated by pip-compile-multi
# To update, run: # To update, run:
# #
# pip-compile requirements/typing.in # pip-compile-multi
# #
cffi==1.15.0 cffi==1.15.0
# via cryptography # via cryptography
@ -14,13 +15,13 @@ mypy-extensions==0.4.3
# via mypy # via mypy
pycparser==2.21 pycparser==2.21
# via cffi # via cffi
tomli==2.0.0 tomli==2.0.1
# via mypy # via mypy
types-contextvars==2.4.1 types-contextvars==2.4.2
# via -r requirements/typing.in # via -r requirements/typing.in
types-dataclasses==0.6.4 types-dataclasses==0.6.4
# via -r requirements/typing.in # via -r requirements/typing.in
types-setuptools==57.4.7 types-setuptools==57.4.9
# via -r requirements/typing.in # via -r requirements/typing.in
typing-extensions==4.0.1 typing-extensions==4.0.1
# via mypy # via mypy

View file

@ -2,6 +2,7 @@ import gc
import re import re
import time import time
import uuid import uuid
import warnings
import weakref import weakref
from datetime import datetime from datetime import datetime
from platform import python_implementation from platform import python_implementation
@ -1525,8 +1526,11 @@ def test_server_name_subdomain():
rv = client.get("/", "https://dev.local") rv = client.get("/", "https://dev.local")
assert rv.data == b"default" assert rv.data == b"default"
# suppress Werkzeug 1.0 warning about name mismatch # suppress Werkzeug 0.15 warning about name mismatch
with pytest.warns(None): with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "Current server name", UserWarning, "flask.app"
)
rv = client.get("/", "http://foo.localhost") rv = client.get("/", "http://foo.localhost")
assert rv.status_code == 404 assert rv.status_code == 404
@ -1893,7 +1897,10 @@ def test_subdomain_matching_other_name(matching):
return "", 204 return "", 204
# suppress Werkzeug 0.15 warning about name mismatch # suppress Werkzeug 0.15 warning about name mismatch
with pytest.warns(None): with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "Current server name", UserWarning, "flask.app"
)
# ip address can't match name # ip address can't match name
rv = client.get("/", "http://127.0.0.1:3000/") rv = client.get("/", "http://127.0.0.1:3000/")
assert rv.status_code == 404 if matching else 204 assert rv.status_code == 404 if matching else 204

View file

@ -1,3 +1,5 @@
import warnings
import pytest import pytest
import flask import flask
@ -81,7 +83,10 @@ def test_proper_test_request_context(app):
) )
# suppress Werkzeug 0.15 warning about name mismatch # suppress Werkzeug 0.15 warning about name mismatch
with pytest.warns(None): with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", "Current server name", UserWarning, "flask.app"
)
with app.test_request_context( with app.test_request_context(
"/", environ_overrides={"HTTP_HOST": "localhost"} "/", environ_overrides={"HTTP_HOST": "localhost"}
): ):