Skip to content
Myr

Merge branch '2.0.x'

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 9039534, 0cfce9a · Browse files · 11 files+76 added−44 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+76 added−44 removed

  • tests:+30 added−27 removed
  • other:+46 added−17 removed

11 files+76 added−44 removed

modified:docs/conf.py+3 added-3 removed
47 unmodified lines
48 ProjectLink("Chat", "https://discord.gg/pallets"),49 ]50}51html_sidebars = {52 "index": ["project.html", "localtoc.html", "searchbox.html"],53 "**": ["localtoc.html", "relations.html", "searchbox.html"],52 "index": ["project.html", "localtoc.html", "searchbox.html", "ethicalads.html"],53 "**": ["localtoc.html", "relations.html", "searchbox.html", "ethicalads.html"],54}55singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}55singlehtml_sidebars = {"index": ["project.html", "localtoc.html", "ethicalads.html"]}56html_static_path = ["_static"]57html_favicon = "_static/flask-icon.png"58html_logo = "_static/flask-icon.png"59html_title = f"Flask Documentation ({version})"
39 unmodified lines
modified:docs/quickstart.rst+2 added-2 removed
244 unmodified lines
245246 @app.route('/user/<username>')247 def show_user_profile(username):248 # show the user profile for that user249 return f'User {username}'249 return f'User {escape(username)}'250251 @app.route('/post/<int:post_id>')252 def show_post(post_id):253 # show the post with the given id, the id is an integer
1 unmodified line
255256 @app.route('/path/<path:subpath>')257 def show_subpath(subpath):258 # show the subpath after /path/259 return f'Subpath {subpath}'259 return f'Subpath {escape(subpath)}'260261Converter types:262263========== ==========================================
675 unmodified lines
modified:requirements/dev.txt+6 added-6 removed
16 unmodified lines
17blinker==1.418 # via -r requirements/tests.in19certifi==2020.12.520 # via requests21cfgv==3.2.021cfgv==3.3.022 # via pre-commit23chardet==4.0.024 # via requests25click==8.0.025click==8.0.126 # via pip-tools27distlib==0.3.128 # via virtualenv29docutils==0.16
13 unmodified lines
43imagesize==1.2.044 # via sphinx45iniconfig==1.1.146 # via pytest47jinja2==3.0.047jinja2==3.0.148 # via sphinx49markupsafe==2.0.049markupsafe==2.0.150 # via jinja251mypy-extensions==0.4.352 # via mypy53mypy==0.812
5 unmodified lines
59 # pallets-sphinx-themes60 # pytest61 # sphinx62 # tox63pallets-sphinx-themes==2.0.063pallets-sphinx-themes==2.0.164 # via -r requirements/docs.in65pep517==0.10.066 # via pip-tools67pip-tools==6.1.0
33 unmodified lines
101sphinx-issues==1.2.0102 # via -r requirements/docs.in103sphinx-tabs==3.0.0104 # via -r requirements/docs.in105git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3105sphinx==4.0.2106 # via107 # -r requirements/docs.in108 # pallets-sphinx-themes109 # sphinx-issues
38 unmodified lines
modified:requirements/docs.in+1 added-1 removed
1Pallets-Sphinx-Themes2git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3 # https://github.com/sphinx-doc/sphinx/issues/9212Sphinx3sphinx-issues4sphinxcontrib-log-cabinet5sphinx-tabs
modified:requirements/docs.txt+4 added-4 removed
18 unmodified lines
19idna==2.1020 # via requests21imagesize==1.2.022 # via sphinx23jinja2==3.0.023jinja2==3.0.124 # via sphinx25markupsafe==2.0.025markupsafe==2.0.126 # via jinja227packaging==20.928 # via29 # pallets-sphinx-themes30 # sphinx31pallets-sphinx-themes==2.0.031pallets-sphinx-themes==2.0.132 # via -r requirements/docs.in33pygments==2.9.034 # via35 # sphinx
9 unmodified lines
45sphinx-issues==1.2.046 # via -r requirements/docs.in47sphinx-tabs==3.0.048 # via -r requirements/docs.in49git+https://github.com/sphinx-doc/sphinx.git@96dbe5e349sphinx==4.0.250 # via51 # -r requirements/docs.in52 # pallets-sphinx-themes53 # sphinx-issues
21 unmodified lines
modified:src/flask/blueprints.py+2 added
352 unmodified lines
353 if state.url_prefix is not None and bp_url_prefix is not None:354 bp_options["url_prefix"] = (355 state.url_prefix.rstrip("/") + "/" + bp_url_prefix.lstrip("/")356 )357 else:358 bp_options["url_prefix"] = state.url_prefix359360 bp_options["name_prefix"] = options.get("name_prefix", "") + self.name + "."361 blueprint.register(app, bp_options)362
190 unmodified lines
modified:src/flask/config.py+25 added
200 unmodified lines
201 raise202203 return self.from_mapping(obj)204205 def from_json(self, filename: str, silent: bool = False) -> bool:206 """Update the values in the config from a JSON file. The loaded207 data is passed to the :meth:`from_mapping` method.208209 :param filename: The path to the JSON file. This can be an210 absolute path or relative to the config root path.211 :param silent: Ignore the file if it doesn't exist.212213 .. deprecated:: 2.0.0214 Will be removed in Flask 2.1. Use :meth:`from_file` instead.215 This was removed early in 2.0.0, was added back in 2.0.1.216217 .. versionadded:: 0.11218 """219 import warnings220 from . import json221222 warnings.warn(223 "'from_json' is deprecated and will be removed in Flask"224 " 2.1. Use 'from_file(path, json.load)' instead.",225 DeprecationWarning,226 stacklevel=2,227 )228 return self.from_file(filename, json.load, silent=silent)229230 def from_mapping(231 self, mapping: t.Optional[t.Mapping[str, t.Any]] = None, **kwargs: t.Any232 ) -> bool:233 """Updates the config like :meth:`update` ignoring items with non-upper
58 unmodified lines
modified:src/flask/typing.py+1 added-1 removed
1import typing as t234if t.TYPE_CHECKING:5 from _typeshed.wsgi import WSGIApplication # noqa: F4016 from werkzeug.datastructures import Headers # noqa: F4016 from wsgiref.types import WSGIApplication # noqa: F4017 from .wrappers import Response # noqa: F40189# The possible types that are directly convertible or are a Response object.10ResponseValue = t.Union[
36 unmodified lines
modified:tests/test_blueprints.py+14 added
866 unmodified lines
867 assert client.get("/parent/").data == b"Parent"868 assert client.get("/parent/child/").data == b"Child"869 assert client.get("/parent/child/grandchild/").data == b"Grandchild"870 assert client.get("/parent/child/orange/").data == b"Apple"871872873def test_nested_blueprint_url_prefix_only_parent_prefix(app, client):874 parent = flask.Blueprint("parent", __name__)875 child = flask.Blueprint("child", __name__)876877 @child.route("/child-endpoint")878 def child_index():879 return "Child"880881 parent.register_blueprint(child)882 app.register_blueprint(parent, url_prefix="/parent")883884 assert client.get("/parent/child-endpoint").data == b"Child"
modified:tests/test_cli.py+16 added-27 removed
3 unmodified lines
4import ssl5import sys6import types7from functools import partial8from pathlib import Path9from unittest.mock import patch1011import click12import pytest
16 unmodified lines
29from flask.cli import run_command30from flask.cli import ScriptInfo31from flask.cli import with_appcontext3232cwd = os.getcwd()33test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test_apps"))33cwd = Path.cwd()34test_path = (Path(__file__) / ".." / "test_apps").resolve()353637@pytest.fixture38def runner():
113 unmodified lines
152 "value,path,result",153 (154 ("test", cwd, "test"),155 ("test.py", cwd, "test"),155 ("a/test", os.path.join(cwd, "a"), "test"),156 ("a/test", cwd / "a", "test"),157 ("test/__init__.py", cwd, "test"),158 ("test/__init__", cwd, "test"),159 # nested package160 (160 os.path.join(test_path, "cliapp", "inner1", "__init__"),161 test_path / "cliapp" / "inner1" / "__init__",162 test_path,163 "cliapp.inner1",164 ),165 (165 os.path.join(test_path, "cliapp", "inner1", "inner2"),166 test_path / "cliapp" / "inner1" / "inner2",167 test_path,168 "cliapp.inner1.inner2",169 ),170 # dotted name171 ("test.a.b", cwd, "test.a.b"),171 (os.path.join(test_path, "cliapp.app"), test_path, "cliapp.app"),172 (test_path / "cliapp.app", test_path, "cliapp.app"),173 # not a Python file, will be caught during import173 (174 os.path.join(test_path, "cliapp", "message.txt"),175 test_path,176 "cliapp.message.txt",177 ),174 (test_path / "cliapp" / "message.txt", test_path, "cliapp.message.txt"),175 ),176)177def test_prepare_import(request, value, path, result):178 """Expect the correct path to be set and the correct import and app names
10 unmodified lines
189190 request.addfinalizer(reset_path)191192 assert prepare_import(value) == result196 assert sys.path[0] == path193 assert sys.path[0] == str(path)194195196@pytest.mark.parametrize(197 "iname,aname,result",
76 unmodified lines
274 assert app.name == "testapp"275 assert obj.load_app() is app276277 # import app with module's absolute path281 cli_app_path = os.path.abspath(282 os.path.join(os.path.dirname(__file__), "test_apps", "cliapp", "app.py")283 )278 cli_app_path = str(test_path / "cliapp" / "app.py")279280 obj = ScriptInfo(app_import_path=cli_app_path)281 app = obj.load_app()282 assert app.name == "testapp"283 assert obj.load_app() is app
13 unmodified lines
297 obj = ScriptInfo()298 pytest.raises(NoAppException, obj.load_app)299300 # import app from wsgi.py in current directory305 monkeypatch.chdir(306 os.path.abspath(307 os.path.join(os.path.dirname(__file__), "test_apps", "helloworld")308 )309 )301 monkeypatch.chdir(test_path / "helloworld")302 obj = ScriptInfo()303 app = obj.load_app()304 assert app.name == "hello"305306 # import app from app.py in current directory315 monkeypatch.chdir(316 os.path.abspath(os.path.join(os.path.dirname(__file__), "test_apps", "cliapp"))317 )307 monkeypatch.chdir(test_path / "cliapp")308 obj = ScriptInfo()309 app = obj.load_app()310 assert app.name == "testapp"311
190 unmodified lines
502503 monkeypatch.setenv("EGGS", "3")504 monkeypatch.chdir(test_path)505 assert load_dotenv()516 assert os.getcwd() == test_path506 assert Path.cwd() == test_path507 # .flaskenv doesn't overwrite .env508 assert os.environ["FOO"] == "env"509 # set only in .flaskenv510 assert os.environ["BAR"] == "bar"
11 unmodified lines
522def test_dotenv_path(monkeypatch):523 for item in ("FOO", "BAR", "EGGS"):524 monkeypatch._setitem.append((os.environ, item, notset))525536 cwd = os.getcwd()537 load_dotenv(os.path.join(test_path, ".flaskenv"))538 assert os.getcwd() == cwd526 load_dotenv(test_path / ".flaskenv")527 assert Path.cwd() == cwd528 assert "FOO" in os.environ529530531def test_dotenv_optional(monkeypatch):
130 unmodified lines
modified:CHANGES.rst+2 added
29 unmodified lines
30 a ``url_prefix`` value. :issue:`4037`31- Roll back a change to the order that URL matching was done. The32 URL is again matched after the session is loaded, so the session is33 available in custom URL converters. :issue:`4053`34- Re-add deprecated ``Config.from_json``, which was accidentally35 removed early. :issue:`4078`363738Version 2.0.039-------------
1116 unmodified lines