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 aa1d34d, 3b83d0c · Browse files · 11 files·+43 added−42 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+43 added−42 removed
- other:+43 added−42 removed
Provenance
- Commit
f4a2c35- Tree
d3a378e- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
aa1d34d- Parent 2
3b83d0c
11 files changed+43 added−42 removed
modified:docs/debugging.rst+1 added-1 removed
67 unmodified lines68 > flask run69 70 ``FLASK_ENV`` can only be set as an environment variable. When running71 from Python code, passing ``debug=True`` enables debug mode, which is72-mostly equivalent. Debug mode can be controled separately from72+mostly equivalent. Debug mode can be controlled separately from73 ``FLASK_ENV`` with the ``FLASK_DEBUG`` environment variable as well.74 75 .. code-block:: python76 57 unmodified linesmodified:requirements/dev.txt+13 added-13 removed
20 unmodified lines21 cffi==1.14.622 # via cryptography23 cfgv==3.3.124 # via pre-commit25-charset-normalizer==2.0.425+charset-normalizer==2.0.626 # via requests27 click==8.0.128 # via pip-tools29-cryptography==3.4.829+cryptography==35.0.030 # via -r requirements/typing.in31-distlib==0.3.231+distlib==0.3.332 # via virtualenv33 docutils==0.1634 # via35 # sphinx36 # sphinx-tabs37-filelock==3.0.1237+filelock==3.2.038 # via39 # tox40 # virtualenv41-greenlet==1.1.141+greenlet==1.1.242 # via -r requirements/tests.in43-identify==2.2.1343+identify==2.2.1544 # via pre-commit45 idna==3.246 # via requests47 imagesize==1.2.019 unmodified lines67 pallets-sphinx-themes==2.0.168 # via -r requirements/docs.in69 pep517==0.11.070 # via pip-tools71-pip-tools==6.2.071+pip-tools==6.3.072 # via -r requirements/dev.in73-platformdirs==2.3.073+platformdirs==2.4.074 # via virtualenv75 pluggy==1.0.076 # via77 # pytest27 unmodified lines105 # tox106 # virtualenv107 snowballstemmer==2.1.0108 # via sphinx109-sphinx==4.1.2109+sphinx==4.2.0110 # via111 # -r requirements/docs.in112 # pallets-sphinx-themes113 # sphinx-issues24 unmodified lines138 # pytest139 # tox140 tomli==1.2.1141 # via pep517142-tox==3.24.3142+tox==3.24.4143 # via -r requirements/dev.in144 types-contextvars==0.1.4145 # via -r requirements/typing.in146 types-dataclasses==0.1.7147 # via -r requirements/typing.in148-types-setuptools==57.0.2148+types-setuptools==57.4.0149 # via -r requirements/typing.in150 typing-extensions==3.10.0.2151 # via mypy152-urllib3==1.26.6152+urllib3==1.26.7153 # via requests154-virtualenv==20.7.2154+virtualenv==20.8.1155 # via156 # pre-commit157 # tox158 wheel==0.37.05 unmodified linesmodified:requirements/docs.txt+3 added-3 removed
8 unmodified lines9 babel==2.9.110 # via sphinx11 certifi==2021.5.3012 # via requests13-charset-normalizer==2.0.413+charset-normalizer==2.0.614 # via requests15 docutils==0.1616 # via17 # sphinx23 unmodified lines41 requests==2.26.042 # via sphinx43 snowballstemmer==2.1.044 # via sphinx45-sphinx==4.1.245+sphinx==4.2.046 # via47 # -r requirements/docs.in48 # pallets-sphinx-themes49 # sphinx-issues16 unmodified lines66 sphinxcontrib-qthelp==1.0.367 # via sphinx68 sphinxcontrib-serializinghtml==1.1.569 # via sphinx70-urllib3==1.26.670+urllib3==1.26.771 # via requests72 73 # The following packages are considered to be unsafe in a requirements file:74 # setuptoolsmodified:requirements/tests.txt+1 added-1 removed
8 unmodified lines9 attrs==21.2.010 # via pytest11 blinker==1.412 # via -r requirements/tests.in13-greenlet==1.1.113+greenlet==1.1.214 # via -r requirements/tests.in15 iniconfig==1.1.116 # via pytest17 packaging==21.013 unmodified linesmodified:requirements/typing.txt+2 added-2 removed
4 unmodified lines5 # pip-compile requirements/typing.in6 #7 cffi==1.14.68 # via cryptography9-cryptography==3.4.89+cryptography==35.0.010 # via -r requirements/typing.in11 mypy==0.91012 # via -r requirements/typing.in13 mypy-extensions==0.4.35 unmodified lines19 types-contextvars==0.1.420 # via -r requirements/typing.in21 types-dataclasses==0.1.722 # via -r requirements/typing.in23-types-setuptools==57.0.223+types-setuptools==57.4.024 # via -r requirements/typing.in25 typing-extensions==3.10.0.226 # via mypymodified:src/flask/app.py+2 added-2 removed
1619 unmodified lines1620 from asgiref.sync import async_to_sync as asgiref_async_to_sync1621 except ImportError:1622 raise RuntimeError(1623 "Install Flask with the 'async' extra in order to use async views."1624- )1624+ ) from None1625 1626 # Check that Werkzeug isn't using its fallback ContextVar class.1627 if ContextVar.__module__ == "werkzeug.local":1628 raise RuntimeError(97 unmodified lines1726 f"{e}\nThe view function did not return a valid"1727 " response. The return type must be a string,"1728 " dict, tuple, Response instance, or WSGI"1729 f" callable, but it was a {type(rv).__name__}."1730- ).with_traceback(sys.exc_info()[2])1730+ ).with_traceback(sys.exc_info()[2]) from None1731 else:1732 raise TypeError(1733 "The view function did not return a valid"1734 " response. The return type must be a string,"359 unmodified linesmodified:src/flask/cli.py+14 added-14 removed
67 unmodified lines68 app = call_factory(script_info, app_factory)69 70 if isinstance(app, Flask):71 return app72- except TypeError:72+ except TypeError as e:73 if not _called_with_wrong_args(app_factory):74 raise75+76 raise NoAppException(77 f"Detected factory {attr_name!r} in module {module.__name__!r},"78 " but could not call it without arguments. Use"79 f" \"FLASK_APP='{module.__name__}:{attr_name}(args)'\""80 " to specify arguments."80- )81+ ) from e82 83 raise NoAppException(84 "Failed to find Flask application or factory in module"85 f" {module.__name__!r}. Use 'FLASK_APP={module.__name__}:name'"75 unmodified lines161 expr = ast.parse(app_name.strip(), mode="eval").body162 except SyntaxError:163 raise NoAppException(164 f"Failed to parse {app_name!r} as an attribute name or function call."164- )165+ ) from None166 167 if isinstance(expr, ast.Name):168 name = expr.id169 args = kwargs = None14 unmodified lines184 # literal_eval gives cryptic error messages, show a generic185 # message with the full expression instead.186 raise NoAppException(187 f"Failed to parse arguments as literal values: {app_name!r}."187- )188+ ) from None189 else:190 raise NoAppException(191 f"Failed to parse {app_name!r} as an attribute name or function call."192 )193 194 try:195 attr = getattr(module, name)195- except AttributeError:196+ except AttributeError as e:197 raise NoAppException(198 f"Failed to find attribute {name!r} in {module.__name__!r}."198- )199+ ) from e200 201 # If the attribute is a function, call it with any args and kwargs202 # to get the real application.203 if inspect.isfunction(attr):204 try:205 app = call_factory(script_info, attr, args, kwargs)205- except TypeError:206+ except TypeError as e:207 if not _called_with_wrong_args(attr):208 raise209 210 raise NoAppException(211 f"The factory {app_name!r} in module"212 f" {module.__name__!r} could not be called with the"213 " specified arguments."213- )214+ ) from e215 else:216 app = attr217 218 if isinstance(app, Flask):38 unmodified lines257 __traceback_hide__ = True # noqa: F841258 259 try:260 __import__(module_name)260- except ImportError:261+ except ImportError as e:262 # Reraise the ImportError if it occurred within the imported module.263 # Determine this by checking whether the trace has a depth > 1.264 if sys.exc_info()[2].tb_next:265 raise NoAppException(265- f"While importing {module_name!r}, an ImportError was"266- f" raised:\n\n{traceback.format_exc()}"267- )266+ f"While importing {module_name!r}, an ImportError was raised."267+ ) from e268 elif raise_if_not_found:269- raise NoAppException(f"Could not import {module_name!r}.")269+ raise NoAppException(f"Could not import {module_name!r}.") from e270 else:271 return272 273 module = sys.modules[module_name]450 unmodified lines724 raise click.BadParameter(725 "Using ad-hoc certificates requires the cryptography library.",726 ctx,727 param,728- )728+ ) from None729 730 return value731 732 obj = import_string(value, silent=True)266 unmodified linesmodified:src/flask/debughelpers.py+3 added-2 removed
81 unmodified lines82 class newcls(oldcls):83 def __getitem__(self, key):84 try:85 return oldcls.__getitem__(self, key)86- except KeyError:86+ except KeyError as e:87 if key not in request.form:88 raise89- raise DebugFilesKeyError(request, key)89 90+ raise DebugFilesKeyError(request, key) from e91+92 newcls.__name__ = oldcls.__name__93 newcls.__module__ = oldcls.__module__94 request.files.__class__ = newcls95 77 unmodified linesmodified:src/flask/scaffold.py+1 added-1 removed
713 unmodified lines714 raise KeyError(715 f"'{code_or_exception}' is not a recognized HTTP error"716 " code. Use a subclass of HTTPException with that code"717 " instead."718- )718+ ) from None719 720 self.error_handler_spec[None][code][exc_class] = t.cast(721 "ErrorHandlerCallable[Exception]", f722 )153 unmodified linesmodified:src/flask/signals.py+1 added-1 removed
27 unmodified lines28 def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.Any:29 raise RuntimeError(30 "Signalling support is unavailable because the blinker"31 " library is not installed."32- )32+ ) from None33 34 connect = connect_via = connected_to = temporarily_connected_to = _fail35 disconnect = _fail36 has_receivers_for = receivers_for = _fail20 unmodified linesmodified:.pre-commit-config.yaml+2 added-2 removed
1 ci:2 autoupdate_schedule: monthly3 repos:4 - repo: https://github.com/asottile/pyupgrade5- rev: v2.25.05+ rev: v2.29.06 hooks:7 - id: pyupgrade8 args: ["--py36-plus"]9 - repo: https://github.com/asottile/reorder_python_imports3 unmodified lines13 name: Reorder Python imports (src, tests)14 files: "^(?!examples/)"15 args: ["--application-directories", "src"]16 - repo: https://github.com/psf/black17- rev: 21.8b017+ rev: 21.9b018 hooks:19 - id: black20 - repo: https://github.com/PyCQA/flake821 rev: 3.9.211 unmodified lines