Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88a8ce3

Browse files
committed
Merge branch 'greyli:main' into main
2 parents 8729ba5 + 143ce3f commit 88a8ce3

File tree

11 files changed

+590
-566
lines changed

11 files changed

+590
-566
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Unreleased
1616
- Fix type annotation for ``teardown_request``. :issue:`4093`
1717
- Fix type annotation for ``before_request`` and ``before_app_request``
1818
decorators. :issue:`4104`
19+
- Fixed the issue where typing requires template global
20+
decorators to accept functions with no arguments. :issue:`4098`
1921

2022

2123
Version 2.0.1

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if you doesn't finish the translation in ten days.
168168
- [x] blueprints [@frostming](https://github.com/frostming) Frost Ming
169169
- [ ] changes
170170
- [ ] cli
171-
- [ ] config
171+
- [ ] config [@guiqiqi](https://github.com/guiqiqi) Doge-GUI
172172
- [ ] contributing
173173
- [ ] debugging
174174
- [ ] design
@@ -183,7 +183,7 @@ if you doesn't finish the translation in ten days.
183183
- [ ] quickstart (reserved)
184184
- [ ] reqcontext [@rosekc](https://github.com/rosekc) rosekc
185185
- [ ] security
186-
- [ ] server
186+
- [ ] server [@LeeRnnGii](https://github.com/LeeRnnGii) LeeRnnGii
187187
- [ ] shell [@LTakamori](https://github.com/LTakamori) LTakamori
188188
- [ ] signals
189189
- [ ] templating
@@ -222,7 +222,7 @@ if you doesn't finish the translation in ten days.
222222

223223
- [ ] appdispatch
224224
- [ ] appfactories
225-
- [ ] caching
225+
- [ ] caching [@pk00749](https://github.com/pk00749) York Li
226226
- [ ] celery
227227
- [ ] deferredcallbacks
228228
- [ ] distribute

docs/async-await.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Using ``async`` and ``await``
77

88
Routes, error handlers, before request, after request, and teardown
99
functions can all be coroutine functions if Flask is installed with the
10-
``async`` extra (``pip install flask[async]``). This allows views to be
10+
``async`` extra (``pip install flask[async]``). It requires Python 3.7+
11+
where ``contextvars.ContextVar`` is available. This allows views to be
1112
defined with ``async def`` and use ``await``.
1213

1314
.. code-block:: python

docs/installation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Python Version
88
We recommend using the latest version of Python. Flask supports Python
99
3.6 and newer.
1010

11+
``async`` support in Flask requires Python 3.7+ for ``contextvars.ContextVar``.
12+
1113

1214
Dependencies
1315
------------

docs/locales/zh_CN/LC_MESSAGES/api.po

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Flask 2.1.x\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-05-25 19:31+0800\n"
11+
"POT-Creation-Date: 2021-05-30 19:27+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: zh_CN <[email protected]>\n"
@@ -242,7 +242,7 @@ msgstr ""
242242
#: werkzeug.wrappers.response.Response.get_wsgi_response
243243
#: werkzeug.wrappers.response.Response.make_conditional
244244
#: werkzeug.wrappers.response.Response.set_data
245-
msgid "Parameters"
245+
msgid "参数"
246246
msgstr ""
247247

248248
#: flask.app.Flask:66 of
@@ -453,7 +453,7 @@ msgstr ""
453453
#: werkzeug.wrappers.response.Response.make_conditional
454454
#: werkzeug.wrappers.response.Response.make_sequence
455455
#: werkzeug.wrappers.response.Response.set_data
456-
msgid "Return type"
456+
msgid "返回类型"
457457
msgstr ""
458458

459459
#: flask.app.Flask.add_template_global:1 of
@@ -1407,7 +1407,7 @@ msgstr ""
14071407
#: werkzeug.wrappers.response.Response.get_app_iter
14081408
#: werkzeug.wrappers.response.Response.get_wsgi_headers
14091409
#: werkzeug.wrappers.response.Response.get_wsgi_response
1410-
msgid "Returns"
1410+
msgid "返回"
14111411
msgstr ""
14121412

14131413
#: flask.app.Flask.process_response:10 of
@@ -5303,7 +5303,7 @@ msgid ""
53035303
msgstr ""
53045304

53055305
#: flask.json.tag.TaggedJSONSerializer.register of
5306-
msgid "Raises"
5306+
msgid "引发"
53075307
msgstr ""
53085308

53095309
#: flask.json.tag.TaggedJSONSerializer.register:11 of
@@ -6602,3 +6602,15 @@ msgid ""
66026602
"having to manually configure the application."
66036603
msgstr ""
66046604

6605+
#~ msgid "Parameters"
6606+
#~ msgstr ""
6607+
6608+
#~ msgid "Return type"
6609+
#~ msgstr ""
6610+
6611+
#~ msgid "Returns"
6612+
#~ msgstr ""
6613+
6614+
#~ msgid "Raises"
6615+
#~ msgstr ""
6616+

docs/locales/zh_CN/LC_MESSAGES/async-await.po

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: Flask 2.1.x\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-05-25 19:31+0800\n"
11+
"POT-Creation-Date: 2021-05-30 19:27+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: zh_CN <[email protected]>\n"
@@ -25,34 +25,35 @@ msgstr ""
2525
msgid ""
2626
"Routes, error handlers, before request, after request, and teardown "
2727
"functions can all be coroutine functions if Flask is installed with the "
28-
"``async`` extra (``pip install flask[async]``). This allows views to be "
28+
"``async`` extra (``pip install flask[async]``). It requires Python 3.7+ "
29+
"where ``contextvars.ContextVar`` is available. This allows views to be "
2930
"defined with ``async def`` and use ``await``."
3031
msgstr ""
3132

32-
#: ../../async-await.rst:20
33+
#: ../../async-await.rst:21
3334
msgid "Using ``async`` on Windows on Python 3.8"
3435
msgstr ""
3536

36-
#: ../../async-await.rst:22
37+
#: ../../async-await.rst:23
3738
msgid ""
3839
"Python 3.8 has a bug related to asyncio on Windows. If you encounter "
3940
"something like ``ValueError: set_wakeup_fd only works in main thread``, "
4041
"please upgrade to Python 3.9."
4142
msgstr ""
4243

43-
#: ../../async-await.rst:28
44+
#: ../../async-await.rst:29
4445
msgid "Performance"
4546
msgstr ""
4647

47-
#: ../../async-await.rst:30
48+
#: ../../async-await.rst:31
4849
msgid ""
4950
"Async functions require an event loop to run. Flask, as a WSGI "
5051
"application, uses one worker to handle one request/response cycle. When a"
5152
" request comes in to an async view, Flask will start an event loop in a "
5253
"thread, run the view function there, then return the result."
5354
msgstr ""
5455

55-
#: ../../async-await.rst:35
56+
#: ../../async-await.rst:36
5657
msgid ""
5758
"Each request still ties up one worker, even for async views. The upside "
5859
"is that you can run async code within a view, for example to make "
@@ -61,7 +62,7 @@ msgid ""
6162
"time will remain the same."
6263
msgstr ""
6364

64-
#: ../../async-await.rst:41
65+
#: ../../async-await.rst:42
6566
msgid ""
6667
"**Async is not inherently faster than sync code.** Async is beneficial "
6768
"when performing concurrent IO-bound tasks, but will probably not improve "
@@ -70,11 +71,11 @@ msgid ""
7071
"that wasn't possible natively before."
7172
msgstr ""
7273

73-
#: ../../async-await.rst:49
74+
#: ../../async-await.rst:50
7475
msgid "Background tasks"
7576
msgstr ""
7677

77-
#: ../../async-await.rst:51
78+
#: ../../async-await.rst:52
7879
msgid ""
7980
"Async functions will run in an event loop until they complete, at which "
8081
"stage the event loop will stop. This means any additional spawned tasks "
@@ -83,7 +84,7 @@ msgid ""
8384
"``asyncio.create_task``."
8485
msgstr ""
8586

86-
#: ../../async-await.rst:57
87+
#: ../../async-await.rst:58
8788
msgid ""
8889
"If you wish to use background tasks it is best to use a task queue to "
8990
"trigger background work, rather than spawn tasks in a view function. With"
@@ -93,11 +94,11 @@ msgid ""
9394
"continually."
9495
msgstr ""
9596

96-
#: ../../async-await.rst:66
97+
#: ../../async-await.rst:67
9798
msgid "When to use Quart instead"
9899
msgstr ""
99100

100-
#: ../../async-await.rst:68
101+
#: ../../async-await.rst:69
101102
msgid ""
102103
"Flask's async support is less performant than async-first frameworks due "
103104
"to the way it is implemented. If you have a mainly async codebase it "
@@ -107,7 +108,7 @@ msgid ""
107108
"without requiring multiple worker processes or threads."
108109
msgstr ""
109110

110-
#: ../../async-await.rst:75
111+
#: ../../async-await.rst:76
111112
msgid ""
112113
"It has also already been possible to run Flask with Gevent or Eventlet to"
113114
" get many of the benefits of async request handling. These libraries "
@@ -117,11 +118,11 @@ msgid ""
117118
"to understanding the specific needs of your project."
118119
msgstr ""
119120

120-
#: ../../async-await.rst:87
121+
#: ../../async-await.rst:88
121122
msgid "Extensions"
122123
msgstr ""
123124

124-
#: ../../async-await.rst:89
125+
#: ../../async-await.rst:90
125126
msgid ""
126127
"Flask extensions predating Flask's async support do not expect async "
127128
"views. If they provide decorators to add functionality to views, those "
@@ -131,28 +132,38 @@ msgid ""
131132
"view."
132133
msgstr ""
133134

134-
#: ../../async-await.rst:95
135+
#: ../../async-await.rst:96
135136
msgid ""
136137
"Extension authors can support async functions by utilising the "
137138
":meth:`flask.Flask.ensure_sync` method. For example, if the extension "
138139
"provides a view function decorator add ``ensure_sync`` before calling the"
139140
" decorated function,"
140141
msgstr ""
141142

142-
#: ../../async-await.rst:110
143+
#: ../../async-await.rst:111
143144
msgid ""
144145
"Check the changelog of the extension you want to use to see if they've "
145146
"implemented async support, or make a feature request or PR to them."
146147
msgstr ""
147148

148-
#: ../../async-await.rst:115
149+
#: ../../async-await.rst:116
149150
msgid "Other event loops"
150151
msgstr ""
151152

152-
#: ../../async-await.rst:117
153+
#: ../../async-await.rst:118
153154
msgid ""
154155
"At the moment Flask only supports :mod:`asyncio`. It's possible to "
155156
"override :meth:`flask.Flask.ensure_sync` to change how async functions "
156157
"are wrapped to use a different library."
157158
msgstr ""
158159

160+
#~ msgid ""
161+
#~ "Routes, error handlers, before request, "
162+
#~ "after request, and teardown functions "
163+
#~ "can all be coroutine functions if "
164+
#~ "Flask is installed with the ``async``"
165+
#~ " extra (``pip install flask[async]``). This"
166+
#~ " allows views to be defined with "
167+
#~ "``async def`` and use ``await``."
168+
#~ msgstr ""
169+

0 commit comments

Comments
 (0)