Merge branch 'stable'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parents f61172b, e785166 · Browse files · 21 files·+89 added−112 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
21 files+89 added−112 removed
- tests:+3 added−35 removed
- other:+86 added−77 removed
Provenance
- Commit
b78b5a2- Tree
ae84579- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
f61172b- Parent 2
e785166
21 files changed+89 added−112 removed
modified:.github/workflows/pre-commit.yaml+1 added-1 removed
6 unmodified lines78910111112131415166 unmodified lines main: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 with: python-version: 3.x - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 - uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0 if: ${{ !cancelled() }}modified:.github/workflows/publish.yaml+6 added-6 removed
8 unmodified lines91011121313141516174 unmodified lines2223242526262728293031323334353636373839402 unmodified lines4344454647474849505110 unmodified lines626364656667666768698 unmodified lines outputs: hash: ${{ steps.hash.outputs.hash }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 with: python-version: '3.x' cache: pip cache-dependency-path: requirements*/*.txt4 unmodified lines # Generate hashes used for provenance. - name: generate hash id: hash run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 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 uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0 with: base64-subjects: ${{ needs.build.outputs.hash }} create-release: # Upload the sdist, wheels, and provenance to a GitHub release. They remain2 unmodified lines runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 - name: create release run: > gh release create --draft --repo ${{ github.repository }} ${{ github.ref_name }}10 unmodified lines runs-on: ubuntu-latest permissions: id-token: write steps: - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2 - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 with: packages-dir: artifact/modified:.github/workflows/tests.yaml+3 added-3 removed
23 unmodified lines242526272828293031323 unmodified lines36373839404041424344454646474849505123 unmodified lines - {name: Minimum Versions, python: '3.12', tox: py-min} - {name: Development Versions, python: '3.9', tox: py-dev} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 with: python-version: ${{ matrix.python }} allow-prereleases: true cache: pip3 unmodified lines typing: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 with: python-version: '3.x' cache: pip cache-dependency-path: requirements*/*.txt - name: cache mypy uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 with: path: ./.mypy_cache key: mypy|${{ hashFiles('pyproject.toml') }} - run: pip install tox - run: tox run -e typingmodified:docs/patterns/appfactories.rst+2 added-2 removed
97 unmodified lines98 to the factory like this:99 100 .. code-block:: text101 102- $ flask --app hello:create_app(local_auth=True) run102+ $ flask --app 'hello:create_app(local_auth=True)' run103 104-Then the ``create_app`` factory in ``myapp`` is called with the keyword104+Then the ``create_app`` factory in ``hello`` is called with the keyword105 argument ``local_auth=True``. See :doc:`/cli` for more detail.106 107 Factory Improvements108 --------------------10 unmodified linesmodified:docs/patterns/favicon.rst+5 added-2 removed
22 unmodified lines23 the root path of the domain you either need to configure the web server to24 serve the icon at the root or if you can't do that you're out of luck. If25 however your application is the root you can simply route a redirect::26 27- app.add_url_rule('/favicon.ico',28- redirect_to=url_for('static', filename='favicon.ico'))27+ app.add_url_rule(28+ "/favicon.ico",29+ endpoint="favicon",30+ redirect_to=url_for("static", filename="favicon.ico"),31+ )32 33 If you want to save the extra redirect request you can also write a view34 using :func:`~flask.send_from_directory`::35 21 unmodified linesmodified:docs/patterns/mongoengine.rst+1 added-1 removed
78 unmodified lines79 80 Use the class ``objects`` attribute to make queries. A keyword argument81 looks for an equal value on the field. ::82 83- bttf = Movies.objects(title="Back To The Future").get_or_404()83+ bttf = Movie.objects(title="Back To The Future").get_or_404()84 85 Query operators may be used by concatenating them with the field name86 using a double-underscore. ``objects``, and queries returned by87 calling it, are iterable. ::16 unmodified linesmodified:docs/conf.py+1 added
24 unmodified lines25 autodoc_preserve_defaults = True26 extlinks = {27 "issue": ("https://github.com/pallets/flask/issues/%s", "#%s"),28 "pr": ("https://github.com/pallets/flask/pull/%s", "#%s"),29+ "ghsa": ("https://github.com/pallets/flask/security/advisories/GHSA-%s", "GHSA-%s"),30 }31 intersphinx_mapping = {32 "python": ("https://docs.python.org/3/", None),33 "werkzeug": ("https://werkzeug.palletsprojects.com/", None),68 unmodified linesmodified:docs/web-security.rst-13 removed
267 unmodified lines268 269 .. _samesite_support: https://caniuse.com/#feat=same-site-cookie-attribute270 271 272-HTTP Public Key Pinning (HPKP)273-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~274-275-This tells the browser to authenticate with the server using only the specific276-certificate key to prevent MITM attacks.277-278-.. warning::279- Be careful when enabling this, as it is very difficult to undo if you set up280- or upgrade your key incorrectly.281-282-- https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning283-284-272 Copy/Paste to Terminal273 ----------------------274 275 Hidden characters such as the backspace character (``\b``, ``^H``) can20 unmodified linesmodified:requirements/dev.txt+27 added-23 removed
10 unmodified lines11 asgiref==3.8.112 # via13 # -r /Users/david/Projects/flask/requirements/tests.txt14 # -r /Users/david/Projects/flask/requirements/typing.txt15-babel==2.16.015+babel==2.17.016 # via17 # -r /Users/david/Projects/flask/requirements/docs.txt18 # sphinx19-cachetools==5.5.019+cachetools==5.5.220 # via tox21-certifi==2024.8.3021+certifi==2025.1.3122 # via23 # -r /Users/david/Projects/flask/requirements/docs.txt24 # requests25 cffi==1.17.13 unmodified lines29 cfgv==3.4.030 # via pre-commit31 chardet==5.2.032 # via tox33-charset-normalizer==3.4.033+charset-normalizer==3.4.134 # via35 # -r /Users/david/Projects/flask/requirements/docs.txt36 # requests37 colorama==0.4.638 # via tox39-cryptography==43.0.339+cryptography==44.0.240 # via -r /Users/david/Projects/flask/requirements/typing.txt41 distlib==0.3.942 # via virtualenv43 docutils==0.21.244 # via45 # -r /Users/david/Projects/flask/requirements/docs.txt46 # sphinx47 # sphinx-tabs48-filelock==3.16.148+filelock==3.18.049 # via50 # tox51 # virtualenv52-identify==2.6.252+identify==2.6.953 # via pre-commit54 idna==3.1055 # via56 # -r /Users/david/Projects/flask/requirements/docs.txt1 unmodified line58 imagesize==1.4.159 # via60 # -r /Users/david/Projects/flask/requirements/docs.txt61 # sphinx62-iniconfig==2.0.062+iniconfig==2.1.063 # via64 # -r /Users/david/Projects/flask/requirements/tests.txt65 # -r /Users/david/Projects/flask/requirements/typing.txt66 # pytest67-jinja2==3.1.467+jinja2==3.1.668 # via69 # -r /Users/david/Projects/flask/requirements/docs.txt70 # sphinx71 markupsafe==3.0.272 # via73 # -r /Users/david/Projects/flask/requirements/docs.txt74 # jinja275-mypy==1.13.075+mypy==1.15.076 # via -r /Users/david/Projects/flask/requirements/typing.txt77 mypy-extensions==1.0.078 # via79 # -r /Users/david/Projects/flask/requirements/typing.txt14 unmodified lines94 # sphinx95 # tox96 pallets-sphinx-themes==2.3.097 # via -r /Users/david/Projects/flask/requirements/docs.txt98-platformdirs==4.3.698+platformdirs==4.3.799 # via100 # tox101 # virtualenv102 pluggy==1.5.01 unmodified line104 # -r /Users/david/Projects/flask/requirements/tests.txt105 # -r /Users/david/Projects/flask/requirements/typing.txt106 # pytest107 # tox108-pre-commit==4.0.1108+pre-commit==4.2.0109 # via -r dev.in110 pycparser==2.22111 # via112 # -r /Users/david/Projects/flask/requirements/typing.txt113 # cffi114-pygments==2.18.0114+pygments==2.19.1115 # via116 # -r /Users/david/Projects/flask/requirements/docs.txt117 # sphinx118 # sphinx-tabs119-pyproject-api==1.8.0119+pyproject-api==1.9.0120 # via tox121-pyright==1.1.389121+pyright==1.1.398122 # via -r /Users/david/Projects/flask/requirements/typing.txt123-pytest==8.3.3123+pytest==8.3.5124 # via125 # -r /Users/david/Projects/flask/requirements/tests.txt126 # -r /Users/david/Projects/flask/requirements/typing.txt127-python-dotenv==1.0.1127+python-dotenv==1.1.0128 # via129 # -r /Users/david/Projects/flask/requirements/tests.txt130 # -r /Users/david/Projects/flask/requirements/typing.txt131 pyyaml==6.0.21 unmodified line133 requests==2.32.3134 # via135 # -r /Users/david/Projects/flask/requirements/docs.txt136 # sphinx137+roman-numerals-py==3.1.0138+ # via139+ # -r /Users/david/Projects/flask/requirements/docs.txt140+ # sphinx141 snowballstemmer==2.2.0142 # via143 # -r /Users/david/Projects/flask/requirements/docs.txt144 # sphinx141-sphinx==8.1.3145+sphinx==8.2.3146 # via147 # -r /Users/david/Projects/flask/requirements/docs.txt148 # pallets-sphinx-themes149 # sphinx-notfound-page150 # sphinx-tabs151 # sphinxcontrib-log-cabinet148-sphinx-notfound-page==1.0.4152+sphinx-notfound-page==1.1.0153 # via154 # -r /Users/david/Projects/flask/requirements/docs.txt155 # pallets-sphinx-themes156 sphinx-tabs==3.4.723 unmodified lines180 sphinxcontrib-serializinghtml==2.0.0181 # via182 # -r /Users/david/Projects/flask/requirements/docs.txt183 # sphinx180-tox==4.23.2184+tox==4.25.0185 # via -r dev.in186 types-contextvars==2.4.7.3187 # via -r /Users/david/Projects/flask/requirements/typing.txt188 types-dataclasses==0.6.6189 # via -r /Users/david/Projects/flask/requirements/typing.txt186-typing-extensions==4.12.2190+typing-extensions==4.13.0191 # via192 # -r /Users/david/Projects/flask/requirements/typing.txt193 # mypy194 # pyright191-urllib3==2.2.3195+urllib3==2.3.0196 # via197 # -r /Users/david/Projects/flask/requirements/docs.txt198 # requests195-virtualenv==20.27.1199+virtualenv==20.29.3200 # via201 # pre-commit202 # toxmodified:requirements/docs.txt+10 added-8 removed
4 unmodified lines5 # pip-compile docs.in6 #7 alabaster==1.0.08 # via sphinx9-babel==2.16.09+babel==2.17.010 # via sphinx11-certifi==2024.8.3011+certifi==2025.1.3112 # via requests13-charset-normalizer==3.4.013+charset-normalizer==3.4.114 # via requests15 docutils==0.21.216 # via17 # sphinx1 unmodified line19 idna==3.1020 # via requests21 imagesize==1.4.122 # via sphinx23-jinja2==3.1.423+jinja2==3.1.624 # via sphinx25 markupsafe==3.0.226 # via jinja227 packaging==24.21 unmodified line29 # pallets-sphinx-themes30 # sphinx31 pallets-sphinx-themes==2.3.032 # via -r docs.in33-pygments==2.18.033+pygments==2.19.134 # via35 # sphinx36 # sphinx-tabs37 requests==2.32.338 # via sphinx39+roman-numerals-py==3.1.040+ # via sphinx41 snowballstemmer==2.2.042 # via sphinx41-sphinx==8.1.343+sphinx==8.2.344 # via45 # -r docs.in46 # pallets-sphinx-themes47 # sphinx-notfound-page48 # sphinx-tabs49 # sphinxcontrib-log-cabinet48-sphinx-notfound-page==1.0.450+sphinx-notfound-page==1.1.051 # via pallets-sphinx-themes52 sphinx-tabs==3.4.753 # via -r docs.in54 sphinxcontrib-applehelp==2.0.09 unmodified lines64 sphinxcontrib-qthelp==2.0.065 # via sphinx66 sphinxcontrib-serializinghtml==2.0.067 # via sphinx66-urllib3==2.2.368+urllib3==2.3.069 # via requestsmodified:requirements/tests.txt+3 added-3 removed
4 unmodified lines5 # pip-compile tests.in6 #7 asgiref==3.8.18 # via -r tests.in9-iniconfig==2.0.09+iniconfig==2.1.010 # via pytest11 packaging==24.212 # via pytest13 pluggy==1.5.014 # via pytest15-pytest==8.3.315+pytest==8.3.516 # via -r tests.in17-python-dotenv==1.0.117+python-dotenv==1.1.018 # via -r tests.inmodified:requirements/typing.txt+7 added-7 removed
6 unmodified lines7 asgiref==3.8.18 # via -r typing.in9 cffi==1.17.110 # via cryptography11-cryptography==43.0.311+cryptography==44.0.212 # via -r typing.in13-iniconfig==2.0.013+iniconfig==2.1.014 # via pytest15-mypy==1.13.015+mypy==1.15.016 # via -r typing.in17 mypy-extensions==1.0.018 # via mypy19 nodeenv==1.9.13 unmodified lines23 pluggy==1.5.024 # via pytest25 pycparser==2.2226 # via cffi27-pyright==1.1.38927+pyright==1.1.39828 # via -r typing.in29-pytest==8.3.329+pytest==8.3.530 # via -r typing.in31-python-dotenv==1.0.131+python-dotenv==1.1.032 # via -r typing.in33 types-contextvars==2.4.7.334 # via -r typing.in35 types-dataclasses==0.6.636 # via -r typing.in37-typing-extensions==4.12.237+typing-extensions==4.13.038 # via39 # mypy40 # pyrightmodified:src/flask/app.py+3 added-3 removed
263 unmodified lines264 # Note we do this without checking if static_folder exists.265 # For one, it might be created while the server is running (e.g. during266 # development). Also, Google App Engine stores static files somewhere267 if self.has_static_folder:268- assert (269- bool(static_host) == host_matching270- ), "Invalid static_host/host_matching combination"268+ assert bool(static_host) == host_matching, (269+ "Invalid static_host/host_matching combination"270+ )271 # Use a weakref to avoid creating a reference cycle between the app272 # and the view function (see #3761).273 self_ref = weakref.ref(self)274 self.add_url_rule(1262 unmodified linesmodified:src/flask/cli.py+3 added-1 removed
682 unmodified lines683 684 return super().make_context(info_name, args, parent=parent, **extra)685 686 def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:687- if not args and self.no_args_is_help:687+ if (not args and self.no_args_is_help) or (688+ len(args) == 1 and args[0] in self.get_help_option_names(ctx)689+ ):690 # Attempt to load --env-file and --app early in case they691 # were given as env vars. Otherwise no_args_is_help will not692 # see commands from app.cli.693 _env_file_option.handle_parse_result(ctx, {}, [])442 unmodified linesmodified:src/flask/testing.py+3 added-3 removed
56 unmodified lines57 **kwargs: t.Any,58 ) -> None:59 assert not (base_url or subdomain or url_scheme) or (60 base_url is not None61- ) != bool(62- subdomain or url_scheme63- ), 'Cannot pass "subdomain" or "url_scheme" with "base_url".'61+ ) != bool(subdomain or url_scheme), (62+ 'Cannot pass "subdomain" or "url_scheme" with "base_url".'63+ )64 65 if base_url is None:66 http_host = app.config.get("SERVER_NAME") or "localhost"67 app_root = app.config["APPLICATION_ROOT"]231 unmodified linesmodified:src/flask/typing.py+3 added
1 from __future__ import annotations2 3+import collections.abc as cabc4 import typing as t5 6 if t.TYPE_CHECKING: # pragma: no cover7 from _typeshed.wsgi import WSGIApplication # noqa: F4019 unmodified lines17 # Only dict is actually accepted, but Mapping allows for TypedDict.18 t.Mapping[str, t.Any],19 t.Iterator[str],20 t.Iterator[bytes],21+ cabc.AsyncIterable[str], # for Quart, until App is generic.22+ cabc.AsyncIterable[bytes],23 ]24 25 # the possible types for an individual HTTP header26 # This should be a Union, but mypy doesn't pass unless it's a TypeVar.67 unmodified linesmodified:tests/conftest.py-32 removed
1 import os2-import pkgutil2 import sys3 4 import pytest5 from _pytest import monkeypatch88 unmodified lines94 95 assert leaks == []96 97 99-@pytest.fixture(params=(True, False))100-def limit_loader(request, monkeypatch):101- """Patch pkgutil.get_loader to give loader without get_filename or archive.102-103- This provides for tests where a system has custom loaders, e.g. Google App104- Engine's HardenedModulesHook, which have neither the `get_filename` method105- nor the `archive` attribute.106-107- This fixture will run the testcase twice, once with and once without the108- limitation/mock.109- """110- if not request.param:111- return112-113- class LimitedLoader:114- def __init__(self, loader):115- self.loader = loader116-117- def __getattr__(self, name):118- if name in {"archive", "get_filename"}:119- raise AttributeError(f"Mocking a loader which does not have {name!r}.")120- return getattr(self.loader, name)121-122- old_get_loader = pkgutil.get_loader123-124- def get_loader(*args, **kwargs):125- return LimitedLoader(old_get_loader(*args, **kwargs))126-127- monkeypatch.setattr(pkgutil, "get_loader", get_loader)128-129-98 @pytest.fixture99 def modules_tmp_path(tmp_path, monkeypatch):100 """A temporary directory added to sys.path."""101 rv = tmp_path / "modules_tmp"27 unmodified linesmodified:tests/test_instance_config.py+3 added-3 removed
61 unmodified lines62 assert app.instance_path == os.fspath(project2 / "instance")63 64 65 def test_installed_module_paths(66- modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages, limit_loader66+ modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages67 ):68 (site_packages / "site_app.py").write_text(69 "import flask\napp = flask.Flask(__name__)\n"70 )6 unmodified lines77 )78 79 80 def test_installed_package_paths(81- limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch81+ modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch82 ):83 installed_path = modules_tmp_path / "path"84 installed_path.mkdir()85 monkeypatch.syspath_prepend(installed_path)10 unmodified lines96 )97 98 99 def test_prefix_package_paths(100- limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages100+ modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages101 ):102 app = site_packages / "site_package"103 app.mkdir()104 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")7 unmodified linesmodified:.pre-commit-config.yaml+1 added-1 removed
1 repos:2 - repo: https://github.com/astral-sh/ruff-pre-commit3- rev: v0.7.33+ rev: v0.11.24 hooks:5 - id: ruff6 - id: ruff-format7 - repo: https://github.com/pre-commit/pre-commit-hooks7 unmodified linesmodified:.readthedocs.yaml+1 added
7 unmodified lines8 - requirements: requirements/docs.txt9 - method: pip10 path: .11 sphinx:12+ configuration: docs/conf.py13 builder: dirhtml14 fail_on_warning: truemodified:CHANGES.rst+6 added
10 unmodified lines11 12 Unreleased13 14 - Fix type hint for `cli_runner.invoke`. :issue:`5645`15+- ``flask --help`` loads the app and plugins first to make sure all commands16+ are shown. :issue:5673`17+- Mark sans-io base class as being able to handle views that return18+ ``AsyncIterable``. This is not accurate for Flask, but makes typing easier19+ for Quart. :pr:`5659`20 21 22 Version 3.1.023 -------------93 unmodified lines117 Released 2023-05-01118 119 - Set ``Vary: Cookie`` header when the session is accessed, modified, or refreshed.120 - Update Werkzeug requirement to >=2.3.3 to apply recent bug fixes.121+ :ghsa:`m2qf-hxjv-5gpq`122 123 124 Version 2.3.1125 -------------1494 unmodified lines