Commit graph

4176 commits

Author SHA1 Message Date
David Lord
96ea4be346 deprecate total_seconds 2021-04-15 23:14:53 -07:00
David Lord
b8c778f322 Merge pull request #3962 from pallets/cached-property
locked_cached_property subclasses Werkzeug's cached_property
2021-04-15 23:14:24 -07:00
David Lord
cdbbfda06e locked_cached_property subclasses cached_property 2021-04-15 23:07:28 -07:00
David Lord
d0076a527d consistent versions and deprecation messages 2021-04-15 15:58:24 -07:00
David Lord
41f4af7abf Merge pull request #3960 from pallets/shell-interactive-hook
shell calls sys.__interativehook__
2021-04-14 10:06:50 -07:00
David Lord
962b55b9b6 shell calls sys.__interativehook__
This will set up readline tab and history completion by default.
2021-04-14 10:01:32 -07:00
David Lord
08b192e4b7 Merge pull request #3923 from pgjones/nested
Nested blueprints
2021-04-14 09:30:48 -07:00
pgjones
257c7c5c2a Nested blueprints
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
2021-04-14 09:25:42 -07:00
David Lord
0db61ffbc9 Merge pull request #3957 from pgjones/fix
Bugfix iscoroutinefunction with Python3.7
2021-04-12 11:47:24 -07:00
pgjones
d89398bca9 Bugfix iscoroutinefunction with Python3.7
See this Python bug https://bugs.python.org/issue33261. The
iscoroutinefunction doesn't recognise partially wrapped coroutine
functions as coroutine functions - which is problematic as the
coroutines will be called as if they are sync, which results in
un-awaited coroutines.
2021-04-12 19:38:42 +01:00
David Lord
6e67b908cf Merge pull request #3958 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-12 10:24:22 -07:00
pre-commit-ci[bot]
2e7c872a38 [pre-commit.ci] pre-commit autoupdate 2021-04-12 17:12:29 +00:00
David Lord
49ce03a85a Merge pull request #3412 from pgjones/async
Add `async` support
2021-04-07 05:32:20 -07:00
David Lord
3053c7a39d update async docs 2021-04-06 15:33:06 -07:00
David Lord
bb02c14740 skip async tests if asgiref isn't installed 2021-04-06 15:33:06 -07:00
pgjones
d65f574bff Alter ensure_sync implementation to support extensions
This allows extensions to override the Flask.ensure_sync method and
have the change apply to blueprints as well. Without this change it is
possible for differing blueprints to have differing ensure_sync
approaches depending on the extension used - which would likely result
in event-loop blocking issues.

This also allows blueprints to have a custom ensure_sync, although
this is a by product rather than an expected use case.
2021-04-06 15:33:06 -07:00
dependabot-preview[bot]
eccc69c234 Merge pull request #3955 from pallets/dependabot/pip/urllib3-1.26.4 2021-04-06 17:49:45 +00:00
dependabot-preview[bot]
4a69dc76f7 [Security] Bump urllib3 from 1.26.3 to 1.26.4
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4. **This update includes a security fix.**
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.3...1.26.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-06 17:46:53 +00:00
pgjones
47e0f2aab8 Raise a runtime error if run_async is called without real ContextVars
Werkzeug offers a ContextVar replacement for Python < 3.7, however it
doesn't work across asyncio tasks, hence it makes sense to error out
rather than find there are odd bugs.

Note the docs build requires the latest (dev) Werkzeug due to this
change (to import ContextVar from werkzeug.local).
2021-04-06 09:35:10 -07:00
pgjones
c9f774d650 Add async support
This allows for async functions to be passed to the Flask class
instance, for example as a view function,

    @app.route("/")
    async def index():
        return "Async hello"

this comes with a cost though of poorer performance than using the
sync equivalent.

asgiref is the standard way to run async code within a sync context,
and is used in Django making it a safe and sane choice for this.
2021-04-06 09:35:10 -07:00
David Lord
8fa1fdfc96 Merge pull request #3952 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-05 10:24:22 -07:00
pre-commit-ci[bot]
c2f01f2086 [pre-commit.ci] pre-commit autoupdate 2021-04-05 17:10:21 +00:00
David Lord
463fc8e698 Merge pull request #3943 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-22 10:50:37 -07:00
pre-commit-ci[bot]
9222815beb [pre-commit.ci] pre-commit autoupdate 2021-03-22 17:04:33 +00:00
David Lord
8043b91496 Merge pull request #3937 from pallets/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-15 11:36:59 -07:00
pre-commit-ci[bot]
183cf87f86 [pre-commit.ci] pre-commit autoupdate 2021-03-15 17:00:57 +00:00
David Lord
78e7159e50 Merge pull request #3933 from pallets/more-scaffold
more work on Scaffold base class
2021-03-10 11:02:16 -08:00
David Lord
4421b22db2 only extend on first registration 2021-03-10 10:51:06 -08:00
David Lord
8e0d511d12 remove redundant _register_error_handler 2021-03-10 10:38:17 -08:00
David Lord
9f21e9fe54 remove old note about InternalServerError 2021-03-10 10:38:16 -08:00
David Lord
8bf05e1b1d rewrite Scaffold docs 2021-03-10 10:38:16 -08:00
David Lord
d9db703c8a move _PackageBoundObject into Scaffold 2021-03-10 10:38:13 -08:00
David Lord
4fa78d8a9b Merge pull request #3932 from greyli/set-encoding
Set default encoding to UTF-8 for load_dotenv
2021-03-10 06:30:24 -08:00
Grey Li
5d11a3d105 Set default encoding to UTF-8 for load_dotenv 2021-03-10 21:40:29 +08:00
David Lord
9b01b78f2f Merge pull request #3918 from pgjones/defaultdict 2021-03-08 10:15:26 -08:00
pgjones
264d52f6c5 remove _blueprint_order, dicts are ordered
This code originates from supporting Python 2.4. Dicts are ordered in
supported Pythons as of 3.6. An OrderedDict could be used to indicate
that order matters, but is not since we don't rely on the implementation
differences.
2021-03-08 09:58:12 -08:00
pgjones
708623907d Utilise defaultdicts
This code originates from the Python 2.4 supporting version of Flask,
with defaultdicts being added in 2.5. Using defaultdict makes the
intentional usage clearer, and slightly simplifies the code.
2021-03-08 09:58:12 -08:00
David Lord
49a0f5d769 Merge pull request #3907 from pgjones/sugar
Add syntatic sugar for route registration
2021-03-08 08:57:58 -08:00
pgjones
26932dad46 Add syntatic sugar for route registration
This takes a popular API whereby instead of passing the HTTP method as
an argument to route it is instead used as the method name i.e.

    @app.route("/", methods=["POST"])

is now writeable as,

    @app.post("/")

This is simply syntatic sugar, it doesn't do anything else, but makes
it slightly easier for users.

I've included all the methods that are relevant and aren't auto
generated i.e. not connect, head, options, and trace.
2021-03-08 08:55:14 -08:00
dependabot-preview[bot]
702a1a2626 Merge pull request #3926 from pallets/dependabot/pip/sphinx-3.5.1 2021-03-01 15:25:15 +00:00
dependabot-preview[bot]
1ff0bc6a1d Merge pull request #3925 from pallets/dependabot/pip/tox-3.22.0 2021-03-01 15:22:59 +00:00
dependabot-preview[bot]
65c198c8ca Bump sphinx from 3.4.3 to 3.5.1
Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 3.4.3 to 3.5.1.
- [Release notes](https://github.com/sphinx-doc/sphinx/releases)
- [Changelog](https://github.com/sphinx-doc/sphinx/blob/3.x/CHANGES)
- [Commits](https://github.com/sphinx-doc/sphinx/compare/v3.4.3...v3.5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-01 15:17:54 +00:00
dependabot-preview[bot]
03fdb1eee8 Bump tox from 3.21.4 to 3.22.0
Bumps [tox](https://github.com/tox-dev/tox) from 3.21.4 to 3.22.0.
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/3.21.4...3.22.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-01 15:15:58 +00:00
David Lord
080a0637df Merge pull request #3917 from greyli/fix-date-parse
update json.dumps for http_date changes
2021-02-25 09:51:58 -08:00
Grey Li
2d8caf350e update json.dumps for http_date changes 2021-02-25 09:45:55 -08:00
David Lord
041c463b97 Merge pull request #3922 from pallets/consistency
various cleanup for consistency between projects
2021-02-24 10:35:16 -08:00
David Lord
2aa174b62a move version to setup.cfg 2021-02-24 10:09:50 -08:00
David Lord
9dbfdeb035 docs rename changelog to changes 2021-02-24 10:09:38 -08:00
David Lord
bf473c8e3b update project links 2021-02-24 10:09:15 -08:00
David Lord
25a13f20cc Merge pull request #3916 from greyli/fix-extdev-docs
Remove the mention of Flask-OAuth in the extension dev docs
2021-02-19 07:21:18 -08:00