fastapi 0.112.1__py3-none-any.whl → 0.112.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fastapi might be problematic. Click here for more details.

fastapi/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
2
2
 
3
- __version__ = "0.112.1"
3
+ __version__ = "0.112.2"
4
4
 
5
5
  from starlette import status as status
6
6
 
fastapi/applications.py CHANGED
@@ -1056,7 +1056,7 @@ class FastAPI(Starlette):
1056
1056
  def add_api_route(
1057
1057
  self,
1058
1058
  path: str,
1059
- endpoint: Callable[..., Coroutine[Any, Any, Response]],
1059
+ endpoint: Callable[..., Any],
1060
1060
  *,
1061
1061
  response_model: Any = Default(None),
1062
1062
  status_code: Optional[int] = None,
@@ -342,9 +342,9 @@ def analyze_param(
342
342
  if isinstance(arg, (params.Param, params.Body, params.Depends))
343
343
  ]
344
344
  if fastapi_specific_annotations:
345
- fastapi_annotation: Union[
346
- FieldInfo, params.Depends, None
347
- ] = fastapi_specific_annotations[-1]
345
+ fastapi_annotation: Union[FieldInfo, params.Depends, None] = (
346
+ fastapi_specific_annotations[-1]
347
+ )
348
348
  else:
349
349
  fastapi_annotation = None
350
350
  if isinstance(fastapi_annotation, FieldInfo):
@@ -2343,7 +2343,7 @@ def Security( # noqa: N802
2343
2343
  ```python
2344
2344
  from typing import Annotated
2345
2345
 
2346
- from fastapi import Depends, FastAPI
2346
+ from fastapi import Security, FastAPI
2347
2347
 
2348
2348
  from .db import User
2349
2349
  from .security import get_current_active_user
fastapi/params.py CHANGED
@@ -91,7 +91,7 @@ class Param(FieldInfo):
91
91
  max_length=max_length,
92
92
  discriminator=discriminator,
93
93
  multiple_of=multiple_of,
94
- allow_nan=allow_inf_nan,
94
+ allow_inf_nan=allow_inf_nan,
95
95
  max_digits=max_digits,
96
96
  decimal_places=decimal_places,
97
97
  **extra,
@@ -547,7 +547,7 @@ class Body(FieldInfo):
547
547
  max_length=max_length,
548
548
  discriminator=discriminator,
549
549
  multiple_of=multiple_of,
550
- allow_nan=allow_inf_nan,
550
+ allow_inf_nan=allow_inf_nan,
551
551
  max_digits=max_digits,
552
552
  decimal_places=decimal_places,
553
553
  **extra,
fastapi/routing.py CHANGED
@@ -3,14 +3,16 @@ import dataclasses
3
3
  import email.message
4
4
  import inspect
5
5
  import json
6
- from contextlib import AsyncExitStack
6
+ from contextlib import AsyncExitStack, asynccontextmanager
7
7
  from enum import Enum, IntEnum
8
8
  from typing import (
9
9
  Any,
10
+ AsyncIterator,
10
11
  Callable,
11
12
  Coroutine,
12
13
  Dict,
13
14
  List,
15
+ Mapping,
14
16
  Optional,
15
17
  Sequence,
16
18
  Set,
@@ -67,7 +69,7 @@ from starlette.routing import (
67
69
  websocket_session,
68
70
  )
69
71
  from starlette.routing import Mount as Mount # noqa
70
- from starlette.types import ASGIApp, Lifespan, Scope
72
+ from starlette.types import AppType, ASGIApp, Lifespan, Scope
71
73
  from starlette.websockets import WebSocket
72
74
  from typing_extensions import Annotated, Doc, deprecated
73
75
 
@@ -119,6 +121,23 @@ def _prepare_response_content(
119
121
  return res
120
122
 
121
123
 
124
+ def _merge_lifespan_context(
125
+ original_context: Lifespan[Any], nested_context: Lifespan[Any]
126
+ ) -> Lifespan[Any]:
127
+ @asynccontextmanager
128
+ async def merged_lifespan(
129
+ app: AppType,
130
+ ) -> AsyncIterator[Optional[Mapping[str, Any]]]:
131
+ async with original_context(app) as maybe_original_state:
132
+ async with nested_context(app) as maybe_nested_state:
133
+ if maybe_nested_state is None and maybe_original_state is None:
134
+ yield None # old ASGI compatibility
135
+ else:
136
+ yield {**(maybe_nested_state or {}), **(maybe_original_state or {})}
137
+
138
+ return merged_lifespan # type: ignore[return-value]
139
+
140
+
122
141
  async def serialize_response(
123
142
  *,
124
143
  field: Optional[ModelField] = None,
@@ -454,9 +473,9 @@ class APIRoute(routing.Route):
454
473
  methods = ["GET"]
455
474
  self.methods: Set[str] = {method.upper() for method in methods}
456
475
  if isinstance(generate_unique_id_function, DefaultPlaceholder):
457
- current_generate_unique_id: Callable[
458
- ["APIRoute"], str
459
- ] = generate_unique_id_function.value
476
+ current_generate_unique_id: Callable[[APIRoute], str] = (
477
+ generate_unique_id_function.value
478
+ )
460
479
  else:
461
480
  current_generate_unique_id = generate_unique_id_function
462
481
  self.unique_id = self.operation_id or current_generate_unique_id(self)
@@ -482,9 +501,9 @@ class APIRoute(routing.Route):
482
501
  # By being a new field, no inheritance will be passed as is. A new model
483
502
  # will always be created.
484
503
  # TODO: remove when deprecating Pydantic v1
485
- self.secure_cloned_response_field: Optional[
486
- ModelField
487
- ] = create_cloned_field(self.response_field)
504
+ self.secure_cloned_response_field: Optional[ModelField] = (
505
+ create_cloned_field(self.response_field)
506
+ )
488
507
  else:
489
508
  self.response_field = None # type: ignore
490
509
  self.secure_cloned_response_field = None
@@ -1308,6 +1327,10 @@ class APIRouter(routing.Router):
1308
1327
  self.add_event_handler("startup", handler)
1309
1328
  for handler in router.on_shutdown:
1310
1329
  self.add_event_handler("shutdown", handler)
1330
+ self.lifespan_context = _merge_lifespan_context(
1331
+ self.lifespan_context,
1332
+ router.lifespan_context,
1333
+ )
1311
1334
 
1312
1335
  def get(
1313
1336
  self,
fastapi/utils.py CHANGED
@@ -34,9 +34,9 @@ if TYPE_CHECKING: # pragma: nocover
34
34
  from .routing import APIRoute
35
35
 
36
36
  # Cache for `create_cloned_field`
37
- _CLONED_TYPES_CACHE: MutableMapping[
38
- Type[BaseModel], Type[BaseModel]
39
- ] = WeakKeyDictionary()
37
+ _CLONED_TYPES_CACHE: MutableMapping[Type[BaseModel], Type[BaseModel]] = (
38
+ WeakKeyDictionary()
39
+ )
40
40
 
41
41
 
42
42
  def is_body_allowed_for_status_code(status_code: Union[int, str, None]) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastapi
3
- Version: 0.112.1
3
+ Version: 0.112.2
4
4
  Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
5
5
  Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
6
6
  Classifier: Intended Audience :: Information Technology
@@ -43,7 +43,7 @@ Requires-Dist: fastapi-cli[standard]>=0.0.5; extra == "standard"
43
43
  Requires-Dist: httpx>=0.23.0; extra == "standard"
44
44
  Requires-Dist: jinja2>=2.11.2; extra == "standard"
45
45
  Requires-Dist: python-multipart>=0.0.7; extra == "standard"
46
- Requires-Dist: email_validator>=2.0.0; extra == "standard"
46
+ Requires-Dist: email-validator>=2.0.0; extra == "standard"
47
47
  Requires-Dist: uvicorn[standard]>=0.12.0; extra == "standard"
48
48
  Requires-Dist: fastapi-cli[standard]>=0.0.5; extra == "all"
49
49
  Requires-Dist: httpx>=0.23.0; extra == "all"
@@ -53,7 +53,7 @@ Requires-Dist: itsdangerous>=1.1.0; extra == "all"
53
53
  Requires-Dist: pyyaml>=5.3.1; extra == "all"
54
54
  Requires-Dist: ujson!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,>=4.0.1; extra == "all"
55
55
  Requires-Dist: orjson>=3.2.1; extra == "all"
56
- Requires-Dist: email_validator>=2.0.0; extra == "all"
56
+ Requires-Dist: email-validator>=2.0.0; extra == "all"
57
57
  Requires-Dist: uvicorn[standard]>=0.12.0; extra == "all"
58
58
  Requires-Dist: pydantic-settings>=2.0.0; extra == "all"
59
59
  Requires-Dist: pydantic-extra-types>=2.0.0; extra == "all"
@@ -195,6 +195,8 @@ FastAPI stands on the shoulders of giants:
195
195
 
196
196
  ## Installation
197
197
 
198
+ Create and activate a <a href="https://fastapi.tiangolo.com/virtual-environments/" class="external-link" target="_blank">virtual environment</a> and then install FastAPI:
199
+
198
200
  <div class="termy">
199
201
 
200
202
  ```console
@@ -525,7 +527,7 @@ When you install FastAPI with `pip install "fastapi[standard]"` it comes the `st
525
527
 
526
528
  Used by Pydantic:
527
529
 
528
- * <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email_validator</code></a> - for email validation.
530
+ * <a href="https://github.com/JoshData/python-email-validator" target="_blank"><code>email-validator</code></a> - for email validation.
529
531
 
530
532
  Used by Starlette:
531
533
 
@@ -1,18 +1,18 @@
1
- fastapi-0.112.1.dist-info/METADATA,sha256=DXZ6wUq8_97Y7baE_tdgj78VG-88WZ0CquDFrNDELO0,27356
2
- fastapi-0.112.1.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
- fastapi-0.112.1.dist-info/entry_points.txt,sha256=Nn2-rs4A5_lQZko2b9QqCKQx9Irx0agGbxq3QLgjBxQ,46
4
- fastapi-0.112.1.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
5
- fastapi/__init__.py,sha256=mJPNeiw1woqECVo-LHqyg3k8MTR2Rf9MWiPCLJpgBJQ,1081
1
+ fastapi-0.112.2.dist-info/METADATA,sha256=bnN5StpCV0DjSg7dk8yiEBkSTr_hAjcMHoxYSv4LuIU,27528
2
+ fastapi-0.112.2.dist-info/WHEEL,sha256=rSwsxJWe3vzyR5HCwjWXQruDgschpei4h_giTm0dJVE,90
3
+ fastapi-0.112.2.dist-info/entry_points.txt,sha256=Nn2-rs4A5_lQZko2b9QqCKQx9Irx0agGbxq3QLgjBxQ,46
4
+ fastapi-0.112.2.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
5
+ fastapi/__init__.py,sha256=61dw7I6Jsj1RGSw6HG8Q3fNgxEuX7Y_QoG39NNJ81C8,1081
6
6
  fastapi/__main__.py,sha256=bKePXLdO4SsVSM6r9SVoLickJDcR2c0cTOxZRKq26YQ,37
7
7
  fastapi/_compat.py,sha256=OjE3FUZ0IPXqIJWKhoWKDNCHv4so-FQ-rfN8ngQZeFE,23134
8
- fastapi/applications.py,sha256=h0hVWT7fXS05N3ZAC72mtf1pu5uJmTdJVEw62uUMf7k,176342
8
+ fastapi/applications.py,sha256=Ix-o9pQAWhEDf9J0Q1hZ0nBB1uP72c-Y3oiYzvrwqiM,176316
9
9
  fastapi/background.py,sha256=rouLirxUANrcYC824MSMypXL_Qb2HYg2YZqaiEqbEKI,1768
10
10
  fastapi/cli.py,sha256=OYhZb0NR_deuT5ofyPF2NoNBzZDNOP8Salef2nk-HqA,418
11
11
  fastapi/concurrency.py,sha256=AYLnS4judDUmXsNRICtoKSP0prfYDcS8ehBtYW9JhQQ,1403
12
12
  fastapi/datastructures.py,sha256=b2PEz77XGq-u3Ur1Inwk0AGjOsQZO49yF9C7IPJ15cY,5766
13
13
  fastapi/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  fastapi/dependencies/models.py,sha256=-n-YCxzgVBkurQi49qOTooT71v_oeAhHJ-qQFonxh5o,2494
15
- fastapi/dependencies/utils.py,sha256=rynOrwW6BKSv0bTVDCY1ag4kRsOzJwmmzO31sRKsTzA,30241
15
+ fastapi/dependencies/utils.py,sha256=DBKj3z2oU1U3W89zTc3e6ej6V1Qy1tvx0V5ho_cYVIQ,30243
16
16
  fastapi/encoders.py,sha256=LvwYmFeOz4tVwvgBoC5rvZnbr7hZr73KGrU8O7zSptU,11068
17
17
  fastapi/exception_handlers.py,sha256=MBrIOA-ugjJDivIi4rSsUJBdTsjuzN76q4yh0q1COKw,1332
18
18
  fastapi/exceptions.py,sha256=taNixuFEXb67lI1bnX1ubq8y8TseJ4yoPlWjyP0fTzk,4969
@@ -28,12 +28,12 @@ fastapi/openapi/constants.py,sha256=adGzmis1L1HJRTE3kJ5fmHS_Noq6tIY6pWv_SFzoFDU,
28
28
  fastapi/openapi/docs.py,sha256=XcQq-ZbQdC5sI0gIGu5MoHK1q-OFaqws7-ORTo6sjY4,10348
29
29
  fastapi/openapi/models.py,sha256=PqkxQiqcEgjKuhfUIWPZPQcyTcubtUCB3vcObLsB7VE,15397
30
30
  fastapi/openapi/utils.py,sha256=asSbOKDuagDfpByNQvPy7OM0sqOBdUmqh64BH-n-5f0,22286
31
- fastapi/param_functions.py,sha256=LcVyxFoK-W1gYGaH7H1dGvth1alwwxXouReg4zKSk88,64005
32
- fastapi/params.py,sha256=GB7aNcyBt8xFUVLnLzt8AGJfZAncQJvwd4N8nhjcXHk,28191
31
+ fastapi/param_functions.py,sha256=Xp1h5RBdb-zlatMJ8_USkut2G9HJAgkMx7HBky9wHbM,64006
32
+ fastapi/params.py,sha256=CWumi-CkfxWSg4I2KpPxIvQyKdeW_Lnct9reHnrTwW8,28199
33
33
  fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  fastapi/requests.py,sha256=zayepKFcienBllv3snmWI20Gk0oHNVLU4DDhqXBb4LU,142
35
35
  fastapi/responses.py,sha256=QNQQlwpKhQoIPZTTWkpc9d_QGeGZ_aVQPaDV3nQ8m7c,1761
36
- fastapi/routing.py,sha256=dcQBjxUsO9KT0pmp1ewJzM8qD3wjcZi1BrnyyqYELoE,174150
36
+ fastapi/routing.py,sha256=sUxTddjKa4IokZAOzv6fHTF0MbltBtJv_QRmh4-L_eA,175040
37
37
  fastapi/security/__init__.py,sha256=bO8pNmxqVRXUjfl2mOKiVZLn0FpBQ61VUYVjmppnbJw,881
38
38
  fastapi/security/api_key.py,sha256=_OqUUjEHG5_MT1IPAhXIGJRCPldTBdSww_DegFy_W8Y,9368
39
39
  fastapi/security/base.py,sha256=dl4pvbC-RxjfbWgPtCWd8MVU-7CB2SZ22rJDXVCXO6c,141
@@ -45,6 +45,6 @@ fastapi/staticfiles.py,sha256=iirGIt3sdY2QZXd36ijs3Cj-T0FuGFda3cd90kM9Ikw,69
45
45
  fastapi/templating.py,sha256=4zsuTWgcjcEainMJFAlW6-gnslm6AgOS1SiiDWfmQxk,76
46
46
  fastapi/testclient.py,sha256=nBvaAmX66YldReJNZXPOk1sfuo2Q6hs8bOvIaCep6LQ,66
47
47
  fastapi/types.py,sha256=nFb36sK3DSoqoyo7Miwy3meKK5UdFBgkAgLSzQlUVyI,383
48
- fastapi/utils.py,sha256=lHKngr-TmOx9QzSyA6PXYSvEgxPYUIk5t3u-kZtskEM,8035
48
+ fastapi/utils.py,sha256=T1OYlJBw80LMtKhvU18J6XeTX4_MMPzIGPYcJqI5QVM,8037
49
49
  fastapi/websockets.py,sha256=419uncYObEKZG0YcrXscfQQYLSWoE10jqxVMetGdR98,222
50
- fastapi-0.112.1.dist-info/RECORD,,
50
+ fastapi-0.112.2.dist-info/RECORD,,