fastapi 0.120.2__py3-none-any.whl → 0.120.4__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.120.2"
3
+ __version__ = "0.120.4"
4
4
 
5
5
  from starlette import status as status
6
6
 
@@ -125,60 +125,16 @@ def ensure_multipart_is_installed() -> None:
125
125
  raise RuntimeError(multipart_not_installed_error) from None
126
126
 
127
127
 
128
- def get_param_sub_dependant(
129
- *,
130
- param_name: str,
131
- depends: params.Depends,
132
- path: str,
133
- security_scopes: Optional[List[str]] = None,
134
- ) -> Dependant:
135
- assert depends.dependency
136
- return get_sub_dependant(
137
- depends=depends,
138
- dependency=depends.dependency,
139
- path=path,
140
- name=param_name,
141
- security_scopes=security_scopes,
142
- )
143
-
144
-
145
128
  def get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> Dependant:
146
129
  assert callable(depends.dependency), (
147
130
  "A parameter-less dependency must have a callable dependency"
148
131
  )
149
- return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path)
150
-
151
-
152
- def get_sub_dependant(
153
- *,
154
- depends: params.Depends,
155
- dependency: Callable[..., Any],
156
- path: str,
157
- name: Optional[str] = None,
158
- security_scopes: Optional[List[str]] = None,
159
- ) -> Dependant:
160
- security_requirement = None
161
- security_scopes = security_scopes or []
162
- if isinstance(depends, params.Security):
163
- dependency_scopes = depends.scopes
164
- security_scopes.extend(dependency_scopes)
165
- if isinstance(dependency, SecurityBase):
166
- use_scopes: List[str] = []
167
- if isinstance(dependency, (OAuth2, OpenIdConnect)):
168
- use_scopes = security_scopes
169
- security_requirement = SecurityRequirement(
170
- security_scheme=dependency, scopes=use_scopes
171
- )
172
- sub_dependant = get_dependant(
173
- path=path,
174
- call=dependency,
175
- name=name,
176
- security_scopes=security_scopes,
177
- use_cache=depends.use_cache,
132
+ use_security_scopes: List[str] = []
133
+ if isinstance(depends, params.Security) and depends.scopes:
134
+ use_security_scopes.extend(depends.scopes)
135
+ return get_dependant(
136
+ path=path, call=depends.dependency, security_scopes=use_security_scopes
178
137
  )
179
- if security_requirement:
180
- sub_dependant.security_requirements.append(security_requirement)
181
- return sub_dependant
182
138
 
183
139
 
184
140
  CacheKey = Tuple[Optional[Callable[..., Any]], Tuple[str, ...]]
@@ -282,9 +238,6 @@ def get_dependant(
282
238
  security_scopes: Optional[List[str]] = None,
283
239
  use_cache: bool = True,
284
240
  ) -> Dependant:
285
- path_param_names = get_path_param_names(path)
286
- endpoint_signature = get_typed_signature(call)
287
- signature_params = endpoint_signature.parameters
288
241
  dependant = Dependant(
289
242
  call=call,
290
243
  name=name,
@@ -292,6 +245,17 @@ def get_dependant(
292
245
  security_scopes=security_scopes,
293
246
  use_cache=use_cache,
294
247
  )
248
+ path_param_names = get_path_param_names(path)
249
+ endpoint_signature = get_typed_signature(call)
250
+ signature_params = endpoint_signature.parameters
251
+ if isinstance(call, SecurityBase):
252
+ use_scopes: List[str] = []
253
+ if isinstance(call, (OAuth2, OpenIdConnect)):
254
+ use_scopes = security_scopes
255
+ security_requirement = SecurityRequirement(
256
+ security_scheme=call, scopes=use_scopes
257
+ )
258
+ dependant.security_requirements.append(security_requirement)
295
259
  for param_name, param in signature_params.items():
296
260
  is_path_param = param_name in path_param_names
297
261
  param_details = analyze_param(
@@ -301,11 +265,17 @@ def get_dependant(
301
265
  is_path_param=is_path_param,
302
266
  )
303
267
  if param_details.depends is not None:
304
- sub_dependant = get_param_sub_dependant(
305
- param_name=param_name,
306
- depends=param_details.depends,
268
+ assert param_details.depends.dependency
269
+ use_security_scopes = security_scopes or []
270
+ if isinstance(param_details.depends, params.Security):
271
+ if param_details.depends.scopes:
272
+ use_security_scopes.extend(param_details.depends.scopes)
273
+ sub_dependant = get_dependant(
307
274
  path=path,
308
- security_scopes=security_scopes,
275
+ call=param_details.depends.dependency,
276
+ name=param_name,
277
+ security_scopes=use_security_scopes,
278
+ use_cache=param_details.depends.use_cache,
309
279
  )
310
280
  dependant.dependencies.append(sub_dependant)
311
281
  continue
fastapi/params.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import warnings
2
+ from dataclasses import dataclass
2
3
  from enum import Enum
3
4
  from typing import Any, Callable, Dict, List, Optional, Sequence, Union
4
5
 
@@ -761,26 +762,12 @@ class File(Form): # type: ignore[misc]
761
762
  )
762
763
 
763
764
 
765
+ @dataclass
764
766
  class Depends:
765
- def __init__(
766
- self, dependency: Optional[Callable[..., Any]] = None, *, use_cache: bool = True
767
- ):
768
- self.dependency = dependency
769
- self.use_cache = use_cache
770
-
771
- def __repr__(self) -> str:
772
- attr = getattr(self.dependency, "__name__", type(self.dependency).__name__)
773
- cache = "" if self.use_cache else ", use_cache=False"
774
- return f"{self.__class__.__name__}({attr}{cache})"
767
+ dependency: Optional[Callable[..., Any]] = None
768
+ use_cache: bool = True
775
769
 
776
770
 
771
+ @dataclass
777
772
  class Security(Depends):
778
- def __init__(
779
- self,
780
- dependency: Optional[Callable[..., Any]] = None,
781
- *,
782
- scopes: Optional[Sequence[str]] = None,
783
- use_cache: bool = True,
784
- ):
785
- super().__init__(dependency=dependency, use_cache=use_cache)
786
- self.scopes = scopes or []
773
+ scopes: Optional[Sequence[str]] = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi
3
- Version: 0.120.2
3
+ Version: 0.120.4
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
  License-Expression: MIT
@@ -1,8 +1,8 @@
1
- fastapi-0.120.2.dist-info/METADATA,sha256=a8IsNeNdi5v7EWRxg3Yhp0zPiamaRgtS7gjeLH9zKS0,28394
2
- fastapi-0.120.2.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- fastapi-0.120.2.dist-info/entry_points.txt,sha256=GCf-WbIZxyGT4MUmrPGj1cOHYZoGsNPHAvNkT6hnGeA,61
4
- fastapi-0.120.2.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
5
- fastapi/__init__.py,sha256=EBFXuySE9cFdHp776KGtyn3c2qw3PNEgwUXloTRR1cE,1081
1
+ fastapi-0.120.4.dist-info/METADATA,sha256=od0Sen6zkiBqq9HBk6uidi-DPgYkMjvRwZEGtnADbow,28394
2
+ fastapi-0.120.4.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ fastapi-0.120.4.dist-info/entry_points.txt,sha256=GCf-WbIZxyGT4MUmrPGj1cOHYZoGsNPHAvNkT6hnGeA,61
4
+ fastapi-0.120.4.dist-info/licenses/LICENSE,sha256=Tsif_IFIW5f-xYSy1KlhAy7v_oNEU4lP2cEnSQbMdE4,1086
5
+ fastapi/__init__.py,sha256=yhL-VDMfthNMaLvbI-QYFGaLgnjBvEOE9r0bXW7HErQ,1081
6
6
  fastapi/__main__.py,sha256=bKePXLdO4SsVSM6r9SVoLickJDcR2c0cTOxZRKq26YQ,37
7
7
  fastapi/_compat/__init__.py,sha256=8fa5XmM6_whr6YWuCs7KDdKR_gZ_AMmaxYW7GDn0eng,2718
8
8
  fastapi/_compat/main.py,sha256=WDixlh9_5nfFuwWvbYQJNi8l5nDZdfbl2nMyTriG65c,10978
@@ -18,7 +18,7 @@ fastapi/concurrency.py,sha256=MirfowoSpkMQZ8j_g0ZxaQKpV6eB3G-dB5TgcXCrgEA,1424
18
18
  fastapi/datastructures.py,sha256=VnWKzzE1EW7KLOTRNWeEqlIoJQASCfgdKOOu5EM3H9A,5813
19
19
  fastapi/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  fastapi/dependencies/models.py,sha256=Pjl6vx-4nZ5Tta9kJa3-RfQKkXtCpS09-FhMgs9eWNs,1507
21
- fastapi/dependencies/utils.py,sha256=weAsXzD81nWm5U0LEa3xnXo9VWMmcFfttQ73vC1M0kw,38633
21
+ fastapi/dependencies/utils.py,sha256=riXXDq8LFiq-AomEYtLa80YP0a7zgPrAEF-DE8iB9yk,38104
22
22
  fastapi/encoders.py,sha256=KAMFJ0sz0FFl0Pg4sUiXiuq94av3mLdLZnzeYp9f4wM,11343
23
23
  fastapi/exception_handlers.py,sha256=YVcT8Zy021VYYeecgdyh5YEUjEIHKcLspbkSf4OfbJI,1275
24
24
  fastapi/exceptions.py,sha256=GuwxWZSXM44SbN3NCZXDfw9g2mNM5XM2FXOWPZkcOI4,4994
@@ -36,7 +36,7 @@ fastapi/openapi/docs.py,sha256=9Rypo8GU5gdp2S7SsoyIZSVGp5e3T2T1KTtJBYTCnRs,10370
36
36
  fastapi/openapi/models.py,sha256=m1BNHxf_RiDTK1uCfMre6XZN5y7krZNA62QEP_2EV9s,15625
37
37
  fastapi/openapi/utils.py,sha256=2DkhvMHoHLI58vK4vai_7v9WZ3R5RMB6dGDIAx3snGo,23255
38
38
  fastapi/param_functions.py,sha256=4x6Y5xOjFmujLnbMDXxvF-kdr-l1mZ0bSOTDLoHYj6Q,64044
39
- fastapi/params.py,sha256=SnkGa4nNdmRek6oOELBHcSieRGjYvDPTla3EOl5Zlis,28413
39
+ fastapi/params.py,sha256=5cIkxEkOxYu5junNilxI6UZhoIbaaq5kjhAY2rvrg48,27877
40
40
  fastapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  fastapi/requests.py,sha256=zayepKFcienBllv3snmWI20Gk0oHNVLU4DDhqXBb4LU,142
42
42
  fastapi/responses.py,sha256=QNQQlwpKhQoIPZTTWkpc9d_QGeGZ_aVQPaDV3nQ8m7c,1761
@@ -55,4 +55,4 @@ fastapi/testclient.py,sha256=nBvaAmX66YldReJNZXPOk1sfuo2Q6hs8bOvIaCep6LQ,66
55
55
  fastapi/types.py,sha256=nFb36sK3DSoqoyo7Miwy3meKK5UdFBgkAgLSzQlUVyI,383
56
56
  fastapi/utils.py,sha256=Nedm_1OJnL12uHJ85HTPCO-AHfwxCtXObFpBi_0X4xQ,9010
57
57
  fastapi/websockets.py,sha256=419uncYObEKZG0YcrXscfQQYLSWoE10jqxVMetGdR98,222
58
- fastapi-0.120.2.dist-info/RECORD,,
58
+ fastapi-0.120.4.dist-info/RECORD,,