wellapi 0.2.1__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.
- wellapi/__init__.py +5 -0
- wellapi/__main__.py +3 -0
- wellapi/applications.py +389 -0
- wellapi/awsmodel.py +17 -0
- wellapi/build/__init__.py +0 -0
- wellapi/build/cdk.py +141 -0
- wellapi/build/packager.py +82 -0
- wellapi/build/sam_openapi.py +10 -0
- wellapi/cli/__init__.py +0 -0
- wellapi/cli/main.py +67 -0
- wellapi/convertors.py +89 -0
- wellapi/datastructures.py +383 -0
- wellapi/dependencies/__init__.py +0 -0
- wellapi/dependencies/models.py +138 -0
- wellapi/dependencies/utils.py +923 -0
- wellapi/exceptions.py +53 -0
- wellapi/local/__init__.py +0 -0
- wellapi/local/reloader.py +94 -0
- wellapi/local/router.py +116 -0
- wellapi/local/server.py +154 -0
- wellapi/middleware/__init__.py +0 -0
- wellapi/middleware/base.py +18 -0
- wellapi/middleware/error.py +239 -0
- wellapi/middleware/exceptions.py +74 -0
- wellapi/middleware/main.py +26 -0
- wellapi/models.py +150 -0
- wellapi/openapi/__init__.py +0 -0
- wellapi/openapi/docs.py +344 -0
- wellapi/openapi/models.py +404 -0
- wellapi/openapi/utils.py +535 -0
- wellapi/params.py +481 -0
- wellapi/routing.py +248 -0
- wellapi/security.py +82 -0
- wellapi/utils.py +37 -0
- wellapi-0.2.1.dist-info/METADATA +32 -0
- wellapi-0.2.1.dist-info/RECORD +38 -0
- wellapi-0.2.1.dist-info/WHEEL +4 -0
- wellapi-0.2.1.dist-info/entry_points.txt +2 -0
wellapi/params.py
ADDED
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
from collections.abc import Callable, Sequence
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import AliasChoices, AliasPath
|
|
6
|
+
from pydantic.fields import FieldInfo
|
|
7
|
+
from pydantic_core import PydanticUndefined
|
|
8
|
+
from typing_extensions import deprecated
|
|
9
|
+
|
|
10
|
+
from wellapi.openapi.models import Example
|
|
11
|
+
|
|
12
|
+
_Unset: Any = PydanticUndefined
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ParamTypes(Enum):
|
|
16
|
+
query = "query"
|
|
17
|
+
header = "header"
|
|
18
|
+
path = "path"
|
|
19
|
+
cookie = "cookie"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Param(FieldInfo):
|
|
23
|
+
in_: ParamTypes
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
default: Any = PydanticUndefined,
|
|
28
|
+
*,
|
|
29
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
30
|
+
annotation: Any | None = None,
|
|
31
|
+
alias: str | None = None,
|
|
32
|
+
alias_priority: int | None = _Unset,
|
|
33
|
+
validation_alias: str | AliasPath | AliasChoices | None,
|
|
34
|
+
serialization_alias: str | None = None,
|
|
35
|
+
title: str | None = None,
|
|
36
|
+
description: str | None = None,
|
|
37
|
+
gt: float | None = None,
|
|
38
|
+
ge: float | None = None,
|
|
39
|
+
lt: float | None = None,
|
|
40
|
+
le: float | None = None,
|
|
41
|
+
min_length: int | None = None,
|
|
42
|
+
max_length: int | None = None,
|
|
43
|
+
pattern: str | None = None,
|
|
44
|
+
discriminator: str | None = None,
|
|
45
|
+
strict: bool | None = _Unset,
|
|
46
|
+
multiple_of: float | None = _Unset,
|
|
47
|
+
allow_inf_nan: bool | None = _Unset,
|
|
48
|
+
max_digits: int | None = _Unset,
|
|
49
|
+
decimal_places: int | None = _Unset,
|
|
50
|
+
examples: list[Any] | None = None,
|
|
51
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
52
|
+
deprecated: deprecated | str | bool | None = None,
|
|
53
|
+
include_in_schema: bool = True,
|
|
54
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
55
|
+
**extra: Any,
|
|
56
|
+
):
|
|
57
|
+
self.include_in_schema = include_in_schema
|
|
58
|
+
self.openapi_examples = openapi_examples
|
|
59
|
+
kwargs = dict(
|
|
60
|
+
default=default,
|
|
61
|
+
default_factory=default_factory,
|
|
62
|
+
alias=alias,
|
|
63
|
+
title=title,
|
|
64
|
+
description=description,
|
|
65
|
+
gt=gt,
|
|
66
|
+
ge=ge,
|
|
67
|
+
lt=lt,
|
|
68
|
+
le=le,
|
|
69
|
+
min_length=min_length,
|
|
70
|
+
max_length=max_length,
|
|
71
|
+
discriminator=discriminator,
|
|
72
|
+
multiple_of=multiple_of,
|
|
73
|
+
allow_inf_nan=allow_inf_nan,
|
|
74
|
+
max_digits=max_digits,
|
|
75
|
+
decimal_places=decimal_places,
|
|
76
|
+
**extra,
|
|
77
|
+
)
|
|
78
|
+
if examples is not None:
|
|
79
|
+
kwargs["examples"] = examples
|
|
80
|
+
|
|
81
|
+
current_json_schema_extra = json_schema_extra or extra
|
|
82
|
+
|
|
83
|
+
kwargs.update(
|
|
84
|
+
{
|
|
85
|
+
"annotation": annotation,
|
|
86
|
+
"deprecated": deprecated,
|
|
87
|
+
"alias_priority": alias_priority,
|
|
88
|
+
"validation_alias": validation_alias,
|
|
89
|
+
"serialization_alias": serialization_alias,
|
|
90
|
+
"strict": strict,
|
|
91
|
+
"json_schema_extra": current_json_schema_extra,
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
kwargs["pattern"] = pattern
|
|
95
|
+
|
|
96
|
+
use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset}
|
|
97
|
+
|
|
98
|
+
super().__init__(**use_kwargs)
|
|
99
|
+
|
|
100
|
+
def __repr__(self) -> str:
|
|
101
|
+
return f"{self.__class__.__name__}({self.default})"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class Path(Param):
|
|
105
|
+
in_ = ParamTypes.path
|
|
106
|
+
|
|
107
|
+
def __init__(
|
|
108
|
+
self,
|
|
109
|
+
default: Any = ...,
|
|
110
|
+
*,
|
|
111
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
112
|
+
annotation: Any | None = None,
|
|
113
|
+
alias: str | None = None,
|
|
114
|
+
alias_priority: int | None = _Unset,
|
|
115
|
+
validation_alias: str | AliasPath | AliasChoices | None = None,
|
|
116
|
+
serialization_alias: str | None = None,
|
|
117
|
+
title: str | None = None,
|
|
118
|
+
description: str | None = None,
|
|
119
|
+
gt: float | None = None,
|
|
120
|
+
ge: float | None = None,
|
|
121
|
+
lt: float | None = None,
|
|
122
|
+
le: float | None = None,
|
|
123
|
+
min_length: int | None = None,
|
|
124
|
+
max_length: int | None = None,
|
|
125
|
+
pattern: str | None = None,
|
|
126
|
+
discriminator: str | None = None,
|
|
127
|
+
strict: bool | None = _Unset,
|
|
128
|
+
multiple_of: float | None = _Unset,
|
|
129
|
+
allow_inf_nan: bool | None = _Unset,
|
|
130
|
+
max_digits: int | None = _Unset,
|
|
131
|
+
decimal_places: int | None = _Unset,
|
|
132
|
+
examples: list[Any] | None = None,
|
|
133
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
134
|
+
deprecated: deprecated | str | bool | None = None,
|
|
135
|
+
include_in_schema: bool = True,
|
|
136
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
137
|
+
**extra: Any,
|
|
138
|
+
):
|
|
139
|
+
assert default is ..., "Path parameters cannot have a default value"
|
|
140
|
+
self.in_ = self.in_
|
|
141
|
+
super().__init__(
|
|
142
|
+
default=default,
|
|
143
|
+
default_factory=default_factory,
|
|
144
|
+
annotation=annotation,
|
|
145
|
+
alias=alias,
|
|
146
|
+
alias_priority=alias_priority,
|
|
147
|
+
validation_alias=validation_alias,
|
|
148
|
+
serialization_alias=serialization_alias,
|
|
149
|
+
title=title,
|
|
150
|
+
description=description,
|
|
151
|
+
gt=gt,
|
|
152
|
+
ge=ge,
|
|
153
|
+
lt=lt,
|
|
154
|
+
le=le,
|
|
155
|
+
min_length=min_length,
|
|
156
|
+
max_length=max_length,
|
|
157
|
+
pattern=pattern,
|
|
158
|
+
discriminator=discriminator,
|
|
159
|
+
strict=strict,
|
|
160
|
+
multiple_of=multiple_of,
|
|
161
|
+
allow_inf_nan=allow_inf_nan,
|
|
162
|
+
max_digits=max_digits,
|
|
163
|
+
decimal_places=decimal_places,
|
|
164
|
+
deprecated=deprecated,
|
|
165
|
+
examples=examples,
|
|
166
|
+
openapi_examples=openapi_examples,
|
|
167
|
+
include_in_schema=include_in_schema,
|
|
168
|
+
json_schema_extra=json_schema_extra,
|
|
169
|
+
**extra,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class Query(Param):
|
|
174
|
+
in_ = ParamTypes.query
|
|
175
|
+
|
|
176
|
+
def __init__(
|
|
177
|
+
self,
|
|
178
|
+
default: Any = PydanticUndefined,
|
|
179
|
+
*,
|
|
180
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
181
|
+
annotation: Any | None = None,
|
|
182
|
+
alias: str | None = None,
|
|
183
|
+
alias_priority: int | None = _Unset,
|
|
184
|
+
validation_alias: str | AliasPath | AliasChoices | None = None,
|
|
185
|
+
serialization_alias: str | None = None,
|
|
186
|
+
title: str | None = None,
|
|
187
|
+
description: str | None = None,
|
|
188
|
+
gt: float | None = None,
|
|
189
|
+
ge: float | None = None,
|
|
190
|
+
lt: float | None = None,
|
|
191
|
+
le: float | None = None,
|
|
192
|
+
min_length: int | None = None,
|
|
193
|
+
max_length: int | None = None,
|
|
194
|
+
pattern: str | None = None,
|
|
195
|
+
discriminator: str | None = None,
|
|
196
|
+
strict: bool | None = _Unset,
|
|
197
|
+
multiple_of: float | None = _Unset,
|
|
198
|
+
allow_inf_nan: bool | None = _Unset,
|
|
199
|
+
max_digits: int | None = _Unset,
|
|
200
|
+
decimal_places: int | None = _Unset,
|
|
201
|
+
examples: list[Any] | None = None,
|
|
202
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
203
|
+
deprecated: deprecated | str | bool | None = None,
|
|
204
|
+
include_in_schema: bool = True,
|
|
205
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
206
|
+
**extra: Any,
|
|
207
|
+
):
|
|
208
|
+
super().__init__(
|
|
209
|
+
default=default,
|
|
210
|
+
default_factory=default_factory,
|
|
211
|
+
annotation=annotation,
|
|
212
|
+
alias=alias,
|
|
213
|
+
alias_priority=alias_priority,
|
|
214
|
+
validation_alias=validation_alias,
|
|
215
|
+
serialization_alias=serialization_alias,
|
|
216
|
+
title=title,
|
|
217
|
+
description=description,
|
|
218
|
+
gt=gt,
|
|
219
|
+
ge=ge,
|
|
220
|
+
lt=lt,
|
|
221
|
+
le=le,
|
|
222
|
+
min_length=min_length,
|
|
223
|
+
max_length=max_length,
|
|
224
|
+
pattern=pattern,
|
|
225
|
+
discriminator=discriminator,
|
|
226
|
+
strict=strict,
|
|
227
|
+
multiple_of=multiple_of,
|
|
228
|
+
allow_inf_nan=allow_inf_nan,
|
|
229
|
+
max_digits=max_digits,
|
|
230
|
+
decimal_places=decimal_places,
|
|
231
|
+
deprecated=deprecated,
|
|
232
|
+
examples=examples,
|
|
233
|
+
openapi_examples=openapi_examples,
|
|
234
|
+
include_in_schema=include_in_schema,
|
|
235
|
+
json_schema_extra=json_schema_extra,
|
|
236
|
+
**extra,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class Header(Param):
|
|
241
|
+
in_ = ParamTypes.header
|
|
242
|
+
|
|
243
|
+
def __init__(
|
|
244
|
+
self,
|
|
245
|
+
default: Any = PydanticUndefined,
|
|
246
|
+
*,
|
|
247
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
248
|
+
annotation: Any | None = None,
|
|
249
|
+
alias: str | None = None,
|
|
250
|
+
alias_priority: int | None = _Unset,
|
|
251
|
+
validation_alias: str | AliasPath | AliasChoices | None = None,
|
|
252
|
+
serialization_alias: str | None = None,
|
|
253
|
+
convert_underscores: bool = True,
|
|
254
|
+
title: str | None = None,
|
|
255
|
+
description: str | None = None,
|
|
256
|
+
gt: float | None = None,
|
|
257
|
+
ge: float | None = None,
|
|
258
|
+
lt: float | None = None,
|
|
259
|
+
le: float | None = None,
|
|
260
|
+
min_length: int | None = None,
|
|
261
|
+
max_length: int | None = None,
|
|
262
|
+
pattern: str | None = None,
|
|
263
|
+
discriminator: str | None = None,
|
|
264
|
+
strict: bool | None = _Unset,
|
|
265
|
+
multiple_of: float | None = _Unset,
|
|
266
|
+
allow_inf_nan: bool | None = _Unset,
|
|
267
|
+
max_digits: int | None = _Unset,
|
|
268
|
+
decimal_places: int | None = _Unset,
|
|
269
|
+
examples: list[Any] | None = None,
|
|
270
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
271
|
+
deprecated: deprecated | str | bool | None = None,
|
|
272
|
+
include_in_schema: bool = True,
|
|
273
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
274
|
+
**extra: Any,
|
|
275
|
+
):
|
|
276
|
+
self.convert_underscores = convert_underscores
|
|
277
|
+
super().__init__(
|
|
278
|
+
default=default,
|
|
279
|
+
default_factory=default_factory,
|
|
280
|
+
annotation=annotation,
|
|
281
|
+
alias=alias,
|
|
282
|
+
alias_priority=alias_priority,
|
|
283
|
+
validation_alias=validation_alias,
|
|
284
|
+
serialization_alias=serialization_alias,
|
|
285
|
+
title=title,
|
|
286
|
+
description=description,
|
|
287
|
+
gt=gt,
|
|
288
|
+
ge=ge,
|
|
289
|
+
lt=lt,
|
|
290
|
+
le=le,
|
|
291
|
+
min_length=min_length,
|
|
292
|
+
max_length=max_length,
|
|
293
|
+
pattern=pattern,
|
|
294
|
+
discriminator=discriminator,
|
|
295
|
+
strict=strict,
|
|
296
|
+
multiple_of=multiple_of,
|
|
297
|
+
allow_inf_nan=allow_inf_nan,
|
|
298
|
+
max_digits=max_digits,
|
|
299
|
+
decimal_places=decimal_places,
|
|
300
|
+
deprecated=deprecated,
|
|
301
|
+
examples=examples,
|
|
302
|
+
openapi_examples=openapi_examples,
|
|
303
|
+
include_in_schema=include_in_schema,
|
|
304
|
+
json_schema_extra=json_schema_extra,
|
|
305
|
+
**extra,
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
class Cookie(Param):
|
|
310
|
+
in_ = ParamTypes.cookie
|
|
311
|
+
|
|
312
|
+
def __init__(
|
|
313
|
+
self,
|
|
314
|
+
default: Any = PydanticUndefined,
|
|
315
|
+
*,
|
|
316
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
317
|
+
annotation: Any | None = None,
|
|
318
|
+
alias: str | None = None,
|
|
319
|
+
alias_priority: int | None = _Unset,
|
|
320
|
+
validation_alias: str | AliasPath | AliasChoices | None = None,
|
|
321
|
+
serialization_alias: str | None = None,
|
|
322
|
+
title: str | None = None,
|
|
323
|
+
description: str | None = None,
|
|
324
|
+
gt: float | None = None,
|
|
325
|
+
ge: float | None = None,
|
|
326
|
+
lt: float | None = None,
|
|
327
|
+
le: float | None = None,
|
|
328
|
+
min_length: int | None = None,
|
|
329
|
+
max_length: int | None = None,
|
|
330
|
+
pattern: str | None = None,
|
|
331
|
+
discriminator: str | None = None,
|
|
332
|
+
strict: bool | None = _Unset,
|
|
333
|
+
multiple_of: float | None = _Unset,
|
|
334
|
+
allow_inf_nan: bool | None = _Unset,
|
|
335
|
+
max_digits: int | None = _Unset,
|
|
336
|
+
decimal_places: int | None = _Unset,
|
|
337
|
+
examples: list[Any] | None = None,
|
|
338
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
339
|
+
deprecated: deprecated | str | bool | None = None,
|
|
340
|
+
include_in_schema: bool = True,
|
|
341
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
342
|
+
**extra: Any,
|
|
343
|
+
):
|
|
344
|
+
super().__init__(
|
|
345
|
+
default=default,
|
|
346
|
+
default_factory=default_factory,
|
|
347
|
+
annotation=annotation,
|
|
348
|
+
alias=alias,
|
|
349
|
+
alias_priority=alias_priority,
|
|
350
|
+
validation_alias=validation_alias,
|
|
351
|
+
serialization_alias=serialization_alias,
|
|
352
|
+
title=title,
|
|
353
|
+
description=description,
|
|
354
|
+
gt=gt,
|
|
355
|
+
ge=ge,
|
|
356
|
+
lt=lt,
|
|
357
|
+
le=le,
|
|
358
|
+
min_length=min_length,
|
|
359
|
+
max_length=max_length,
|
|
360
|
+
pattern=pattern,
|
|
361
|
+
discriminator=discriminator,
|
|
362
|
+
strict=strict,
|
|
363
|
+
multiple_of=multiple_of,
|
|
364
|
+
allow_inf_nan=allow_inf_nan,
|
|
365
|
+
max_digits=max_digits,
|
|
366
|
+
decimal_places=decimal_places,
|
|
367
|
+
deprecated=deprecated,
|
|
368
|
+
examples=examples,
|
|
369
|
+
openapi_examples=openapi_examples,
|
|
370
|
+
include_in_schema=include_in_schema,
|
|
371
|
+
json_schema_extra=json_schema_extra,
|
|
372
|
+
**extra,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
class Body(FieldInfo):
|
|
377
|
+
def __init__(
|
|
378
|
+
self,
|
|
379
|
+
default: Any = PydanticUndefined,
|
|
380
|
+
*,
|
|
381
|
+
default_factory: Callable[[], Any] | None = _Unset,
|
|
382
|
+
annotation: Any | None = None,
|
|
383
|
+
embed: bool | None = None,
|
|
384
|
+
media_type: str = "application/json",
|
|
385
|
+
alias: str | None = None,
|
|
386
|
+
alias_priority: int | None = _Unset,
|
|
387
|
+
validation_alias: str | AliasPath | AliasChoices | None = None,
|
|
388
|
+
serialization_alias: str | None = None,
|
|
389
|
+
title: str | None = None,
|
|
390
|
+
description: str | None = None,
|
|
391
|
+
gt: float | None = None,
|
|
392
|
+
ge: float | None = None,
|
|
393
|
+
lt: float | None = None,
|
|
394
|
+
le: float | None = None,
|
|
395
|
+
min_length: int | None = None,
|
|
396
|
+
max_length: int | None = None,
|
|
397
|
+
pattern: str | None = None,
|
|
398
|
+
discriminator: str | None = None,
|
|
399
|
+
strict: bool | None = _Unset,
|
|
400
|
+
multiple_of: float | None = _Unset,
|
|
401
|
+
allow_inf_nan: bool | None = _Unset,
|
|
402
|
+
max_digits: int | None = _Unset,
|
|
403
|
+
decimal_places: int | None = _Unset,
|
|
404
|
+
examples: list[Any] | None = None,
|
|
405
|
+
openapi_examples: dict[str, Example] | None = None,
|
|
406
|
+
deprecated: deprecated | str | bool | None = None,
|
|
407
|
+
include_in_schema: bool = True,
|
|
408
|
+
json_schema_extra: dict[str, Any] | None = None,
|
|
409
|
+
**extra: Any,
|
|
410
|
+
):
|
|
411
|
+
self.embed = embed
|
|
412
|
+
self.media_type = media_type
|
|
413
|
+
self.include_in_schema = include_in_schema
|
|
414
|
+
self.openapi_examples = openapi_examples
|
|
415
|
+
kwargs = dict(
|
|
416
|
+
default=default,
|
|
417
|
+
default_factory=default_factory,
|
|
418
|
+
alias=alias,
|
|
419
|
+
title=title,
|
|
420
|
+
description=description,
|
|
421
|
+
gt=gt,
|
|
422
|
+
ge=ge,
|
|
423
|
+
lt=lt,
|
|
424
|
+
le=le,
|
|
425
|
+
min_length=min_length,
|
|
426
|
+
max_length=max_length,
|
|
427
|
+
discriminator=discriminator,
|
|
428
|
+
multiple_of=multiple_of,
|
|
429
|
+
allow_inf_nan=allow_inf_nan,
|
|
430
|
+
max_digits=max_digits,
|
|
431
|
+
decimal_places=decimal_places,
|
|
432
|
+
**extra,
|
|
433
|
+
)
|
|
434
|
+
if examples is not None:
|
|
435
|
+
kwargs["examples"] = examples
|
|
436
|
+
|
|
437
|
+
current_json_schema_extra = json_schema_extra or extra
|
|
438
|
+
kwargs.update(
|
|
439
|
+
{
|
|
440
|
+
"annotation": annotation,
|
|
441
|
+
"deprecated": deprecated,
|
|
442
|
+
"alias_priority": alias_priority,
|
|
443
|
+
"validation_alias": validation_alias,
|
|
444
|
+
"serialization_alias": serialization_alias,
|
|
445
|
+
"strict": strict,
|
|
446
|
+
"json_schema_extra": current_json_schema_extra,
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
kwargs["pattern"] = pattern
|
|
450
|
+
|
|
451
|
+
use_kwargs = {k: v for k, v in kwargs.items() if v is not _Unset}
|
|
452
|
+
|
|
453
|
+
super().__init__(**use_kwargs)
|
|
454
|
+
|
|
455
|
+
def __repr__(self) -> str:
|
|
456
|
+
return f"{self.__class__.__name__}({self.default})"
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
class Depends:
|
|
460
|
+
def __init__(
|
|
461
|
+
self, dependency: Callable[..., Any] | None = None, *, use_cache: bool = True
|
|
462
|
+
):
|
|
463
|
+
self.dependency = dependency
|
|
464
|
+
self.use_cache = use_cache
|
|
465
|
+
|
|
466
|
+
def __repr__(self) -> str:
|
|
467
|
+
attr = getattr(self.dependency, "__name__", type(self.dependency).__name__)
|
|
468
|
+
cache = "" if self.use_cache else ", use_cache=False"
|
|
469
|
+
return f"{self.__class__.__name__}({attr}{cache})"
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
class Security(Depends):
|
|
473
|
+
def __init__(
|
|
474
|
+
self,
|
|
475
|
+
dependency: Callable[..., Any] | None = None,
|
|
476
|
+
*,
|
|
477
|
+
scopes: Sequence[str] | None = None,
|
|
478
|
+
use_cache: bool = True,
|
|
479
|
+
):
|
|
480
|
+
super().__init__(dependency=dependency, use_cache=use_cache)
|
|
481
|
+
self.scopes = scopes or []
|