Skip to content
Myr

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

21 files+89 added−112 removed

modified:.github/workflows/pre-commit.yaml+1 added-1 removed
modified:.github/workflows/publish.yaml+6 added-6 removed
modified:.github/workflows/tests.yaml+3 added-3 removed
modified:docs/patterns/appfactories.rst+2 added-2 removed
97 unmodified lines
98to the factory like this:99100.. code-block:: text101102 $ flask --app hello:create_app(local_auth=True) run102 $ flask --app 'hello:create_app(local_auth=True)' run103104Then the ``create_app`` factory in ``myapp`` is called with the keyword104Then the ``create_app`` factory in ``hello`` is called with the keyword105argument ``local_auth=True``. See :doc:`/cli` for more detail.106107Factory Improvements108--------------------
10 unmodified lines
modified:docs/patterns/favicon.rst+5 added-2 removed
22 unmodified lines
23the root path of the domain you either need to configure the web server to24serve the icon at the root or if you can't do that you're out of luck. If25however your application is the root you can simply route a redirect::2627 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 )3233If you want to save the extra redirect request you can also write a view34using :func:`~flask.send_from_directory`::35
21 unmodified lines
modified:docs/patterns/mongoengine.rst+1 added-1 removed
78 unmodified lines
7980Use the class ``objects`` attribute to make queries. A keyword argument81looks for an equal value on the field. ::8283 bttf = Movies.objects(title="Back To The Future").get_or_404()83 bttf = Movie.objects(title="Back To The Future").get_or_404()8485Query operators may be used by concatenating them with the field name86using a double-underscore. ``objects``, and queries returned by87calling it, are iterable. ::
16 unmodified lines
modified:docs/conf.py+1 added
24 unmodified lines
25autodoc_preserve_defaults = True26extlinks = {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}31intersphinx_mapping = {32 "python": ("https://docs.python.org/3/", None),33 "werkzeug": ("https://werkzeug.palletsprojects.com/", None),
68 unmodified lines
modified:docs/web-security.rst-13 removed
267 unmodified lines
268269.. _samesite_support: https://caniuse.com/#feat=same-site-cookie-attribute270271272HTTP Public Key Pinning (HPKP)273~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~274275This tells the browser to authenticate with the server using only the specific276certificate key to prevent MITM attacks.277278.. warning::279 Be careful when enabling this, as it is very difficult to undo if you set up280 or upgrade your key incorrectly.281282- https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning283284272Copy/Paste to Terminal273----------------------274275Hidden characters such as the backspace character (``\b``, ``^H``) can
20 unmodified lines
modified:requirements/dev.txt+27 added-23 removed
10 unmodified lines
11asgiref==3.8.112 # via13 # -r /Users/david/Projects/flask/requirements/tests.txt14 # -r /Users/david/Projects/flask/requirements/typing.txt15babel==2.16.015babel==2.17.016 # via17 # -r /Users/david/Projects/flask/requirements/docs.txt18 # sphinx19cachetools==5.5.019cachetools==5.5.220 # via tox21certifi==2024.8.3021certifi==2025.1.3122 # via23 # -r /Users/david/Projects/flask/requirements/docs.txt24 # requests25cffi==1.17.1
3 unmodified lines
29cfgv==3.4.030 # via pre-commit31chardet==5.2.032 # via tox33charset-normalizer==3.4.033charset-normalizer==3.4.134 # via35 # -r /Users/david/Projects/flask/requirements/docs.txt36 # requests37colorama==0.4.638 # via tox39cryptography==43.0.339cryptography==44.0.240 # via -r /Users/david/Projects/flask/requirements/typing.txt41distlib==0.3.942 # via virtualenv43docutils==0.21.244 # via45 # -r /Users/david/Projects/flask/requirements/docs.txt46 # sphinx47 # sphinx-tabs48filelock==3.16.148filelock==3.18.049 # via50 # tox51 # virtualenv52identify==2.6.252identify==2.6.953 # via pre-commit54idna==3.1055 # via56 # -r /Users/david/Projects/flask/requirements/docs.txt
1 unmodified line
58imagesize==1.4.159 # via60 # -r /Users/david/Projects/flask/requirements/docs.txt61 # sphinx62iniconfig==2.0.062iniconfig==2.1.063 # via64 # -r /Users/david/Projects/flask/requirements/tests.txt65 # -r /Users/david/Projects/flask/requirements/typing.txt66 # pytest67jinja2==3.1.467jinja2==3.1.668 # via69 # -r /Users/david/Projects/flask/requirements/docs.txt70 # sphinx71markupsafe==3.0.272 # via73 # -r /Users/david/Projects/flask/requirements/docs.txt74 # jinja275mypy==1.13.075mypy==1.15.076 # via -r /Users/david/Projects/flask/requirements/typing.txt77mypy-extensions==1.0.078 # via79 # -r /Users/david/Projects/flask/requirements/typing.txt
14 unmodified lines
94 # sphinx95 # tox96pallets-sphinx-themes==2.3.097 # via -r /Users/david/Projects/flask/requirements/docs.txt98platformdirs==4.3.698platformdirs==4.3.799 # via100 # tox101 # virtualenv102pluggy==1.5.0
1 unmodified line
104 # -r /Users/david/Projects/flask/requirements/tests.txt105 # -r /Users/david/Projects/flask/requirements/typing.txt106 # pytest107 # tox108pre-commit==4.0.1108pre-commit==4.2.0109 # via -r dev.in110pycparser==2.22111 # via112 # -r /Users/david/Projects/flask/requirements/typing.txt113 # cffi114pygments==2.18.0114pygments==2.19.1115 # via116 # -r /Users/david/Projects/flask/requirements/docs.txt117 # sphinx118 # sphinx-tabs119pyproject-api==1.8.0119pyproject-api==1.9.0120 # via tox121pyright==1.1.389121pyright==1.1.398122 # via -r /Users/david/Projects/flask/requirements/typing.txt123pytest==8.3.3123pytest==8.3.5124 # via125 # -r /Users/david/Projects/flask/requirements/tests.txt126 # -r /Users/david/Projects/flask/requirements/typing.txt127python-dotenv==1.0.1127python-dotenv==1.1.0128 # via129 # -r /Users/david/Projects/flask/requirements/tests.txt130 # -r /Users/david/Projects/flask/requirements/typing.txt131pyyaml==6.0.2
1 unmodified line
133requests==2.32.3134 # via135 # -r /Users/david/Projects/flask/requirements/docs.txt136 # sphinx137roman-numerals-py==3.1.0138 # via139 # -r /Users/david/Projects/flask/requirements/docs.txt140 # sphinx141snowballstemmer==2.2.0142 # via143 # -r /Users/david/Projects/flask/requirements/docs.txt144 # sphinx141sphinx==8.1.3145sphinx==8.2.3146 # via147 # -r /Users/david/Projects/flask/requirements/docs.txt148 # pallets-sphinx-themes149 # sphinx-notfound-page150 # sphinx-tabs151 # sphinxcontrib-log-cabinet148sphinx-notfound-page==1.0.4152sphinx-notfound-page==1.1.0153 # via154 # -r /Users/david/Projects/flask/requirements/docs.txt155 # pallets-sphinx-themes156sphinx-tabs==3.4.7
23 unmodified lines
180sphinxcontrib-serializinghtml==2.0.0181 # via182 # -r /Users/david/Projects/flask/requirements/docs.txt183 # sphinx180tox==4.23.2184tox==4.25.0185 # via -r dev.in186types-contextvars==2.4.7.3187 # via -r /Users/david/Projects/flask/requirements/typing.txt188types-dataclasses==0.6.6189 # via -r /Users/david/Projects/flask/requirements/typing.txt186typing-extensions==4.12.2190typing-extensions==4.13.0191 # via192 # -r /Users/david/Projects/flask/requirements/typing.txt193 # mypy194 # pyright191urllib3==2.2.3195urllib3==2.3.0196 # via197 # -r /Users/david/Projects/flask/requirements/docs.txt198 # requests195virtualenv==20.27.1199virtualenv==20.29.3200 # via201 # pre-commit202 # tox
modified:requirements/docs.txt+10 added-8 removed
4 unmodified lines
5# pip-compile docs.in6#7alabaster==1.0.08 # via sphinx9babel==2.16.09babel==2.17.010 # via sphinx11certifi==2024.8.3011certifi==2025.1.3112 # via requests13charset-normalizer==3.4.013charset-normalizer==3.4.114 # via requests15docutils==0.21.216 # via17 # sphinx
1 unmodified line
19idna==3.1020 # via requests21imagesize==1.4.122 # via sphinx23jinja2==3.1.423jinja2==3.1.624 # via sphinx25markupsafe==3.0.226 # via jinja227packaging==24.2
1 unmodified line
29 # pallets-sphinx-themes30 # sphinx31pallets-sphinx-themes==2.3.032 # via -r docs.in33pygments==2.18.033pygments==2.19.134 # via35 # sphinx36 # sphinx-tabs37requests==2.32.338 # via sphinx39roman-numerals-py==3.1.040 # via sphinx41snowballstemmer==2.2.042 # via sphinx41sphinx==8.1.343sphinx==8.2.344 # via45 # -r docs.in46 # pallets-sphinx-themes47 # sphinx-notfound-page48 # sphinx-tabs49 # sphinxcontrib-log-cabinet48sphinx-notfound-page==1.0.450sphinx-notfound-page==1.1.051 # via pallets-sphinx-themes52sphinx-tabs==3.4.753 # via -r docs.in54sphinxcontrib-applehelp==2.0.0
9 unmodified lines
64sphinxcontrib-qthelp==2.0.065 # via sphinx66sphinxcontrib-serializinghtml==2.0.067 # via sphinx66urllib3==2.2.368urllib3==2.3.069 # via requests
modified:requirements/tests.txt+3 added-3 removed
4 unmodified lines
5# pip-compile tests.in6#7asgiref==3.8.18 # via -r tests.in9iniconfig==2.0.09iniconfig==2.1.010 # via pytest11packaging==24.212 # via pytest13pluggy==1.5.014 # via pytest15pytest==8.3.315pytest==8.3.516 # via -r tests.in17python-dotenv==1.0.117python-dotenv==1.1.018 # via -r tests.in
modified:requirements/typing.txt+7 added-7 removed
6 unmodified lines
7asgiref==3.8.18 # via -r typing.in9cffi==1.17.110 # via cryptography11cryptography==43.0.311cryptography==44.0.212 # via -r typing.in13iniconfig==2.0.013iniconfig==2.1.014 # via pytest15mypy==1.13.015mypy==1.15.016 # via -r typing.in17mypy-extensions==1.0.018 # via mypy19nodeenv==1.9.1
3 unmodified lines
23pluggy==1.5.024 # via pytest25pycparser==2.2226 # via cffi27pyright==1.1.38927pyright==1.1.39828 # via -r typing.in29pytest==8.3.329pytest==8.3.530 # via -r typing.in31python-dotenv==1.0.131python-dotenv==1.1.032 # via -r typing.in33types-contextvars==2.4.7.334 # via -r typing.in35types-dataclasses==0.6.636 # via -r typing.in37typing-extensions==4.12.237typing-extensions==4.13.038 # via39 # mypy40 # pyright
modified:src/flask/app.py+3 added-3 removed
263 unmodified lines
264 # 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 lines
modified:src/flask/cli.py+3 added-1 removed
682 unmodified lines
683684 return super().make_context(info_name, args, parent=parent, **extra)685686 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 lines
modified:src/flask/testing.py+3 added-3 removed
56 unmodified lines
57 **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 )6465 if base_url is None:66 http_host = app.config.get("SERVER_NAME") or "localhost"67 app_root = app.config["APPLICATION_ROOT"]
231 unmodified lines
modified:src/flask/typing.py+3 added
1from __future__ import annotations23import collections.abc as cabc4import typing as t56if t.TYPE_CHECKING: # pragma: no cover7 from _typeshed.wsgi import WSGIApplication # noqa: F401
9 unmodified lines
17 # 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]2425# 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 lines
modified:tests/conftest.py-32 removed
1import os2import pkgutil2import sys34import pytest5from _pytest import monkeypatch
88 unmodified lines
9495 assert leaks == []969799@pytest.fixture(params=(True, False))100def limit_loader(request, monkeypatch):101 """Patch pkgutil.get_loader to give loader without get_filename or archive.102103 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.106107 This fixture will run the testcase twice, once with and once without the108 limitation/mock.109 """110 if not request.param:111 return112113 class LimitedLoader:114 def __init__(self, loader):115 self.loader = loader116117 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)121122 old_get_loader = pkgutil.get_loader123124 def get_loader(*args, **kwargs):125 return LimitedLoader(old_get_loader(*args, **kwargs))126127 monkeypatch.setattr(pkgutil, "get_loader", get_loader)12812998@pytest.fixture99def modules_tmp_path(tmp_path, monkeypatch):100 """A temporary directory added to sys.path."""101 rv = tmp_path / "modules_tmp"
27 unmodified lines
modified:tests/test_instance_config.py+3 added-3 removed
61 unmodified lines
62 assert app.instance_path == os.fspath(project2 / "instance")636465def 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 lines
77 )787980def 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 lines
96 )979899def 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 lines
modified:.pre-commit-config.yaml+1 added-1 removed
1repos: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-hooks
7 unmodified lines
modified:.readthedocs.yaml+1 added
7 unmodified lines
8 - requirements: requirements/docs.txt9 - method: pip10 path: .11sphinx:12 configuration: docs/conf.py13 builder: dirhtml14 fail_on_warning: true
modified:CHANGES.rst+6 added
10 unmodified lines
1112Unreleased1314- 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`202122Version 3.1.023-------------
93 unmodified lines
117Released 2023-05-01118119- 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`122123124Version 2.3.1125-------------
1494 unmodified lines