u-toolkit 0.1.4__py3-none-any.whl → 0.1.5__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.
- u_toolkit/fastapi/cbv.py +16 -7
- u_toolkit/signature.py +2 -3
- {u_toolkit-0.1.4.dist-info → u_toolkit-0.1.5.dist-info}/METADATA +1 -1
- {u_toolkit-0.1.4.dist-info → u_toolkit-0.1.5.dist-info}/RECORD +6 -6
- {u_toolkit-0.1.4.dist-info → u_toolkit-0.1.5.dist-info}/WHEEL +0 -0
- {u_toolkit-0.1.4.dist-info → u_toolkit-0.1.5.dist-info}/entry_points.txt +0 -0
u_toolkit/fastapi/cbv.py
CHANGED
@@ -13,7 +13,11 @@ from u_toolkit.fastapi.helpers import get_depend_from_annotation, is_depend
|
|
13
13
|
from u_toolkit.fastapi.responses import Response, build_responses
|
14
14
|
from u_toolkit.helpers import is_annotated
|
15
15
|
from u_toolkit.merge import deep_merge_dict
|
16
|
-
from u_toolkit.signature import
|
16
|
+
from u_toolkit.signature import (
|
17
|
+
list_parameters,
|
18
|
+
update_parameters,
|
19
|
+
with_parameter,
|
20
|
+
)
|
17
21
|
|
18
22
|
|
19
23
|
class EndpointsClassInterface(Protocol):
|
@@ -304,7 +308,9 @@ class CBV:
|
|
304
308
|
for name, dep in iter_dependencies(cls)
|
305
309
|
]
|
306
310
|
|
307
|
-
|
311
|
+
has_cls_deps = bool(parameters)
|
312
|
+
if has_cls_deps:
|
313
|
+
update_parameters(collect_cls_dependencies, *parameters)
|
308
314
|
|
309
315
|
def new_fn(method_name, kwargs):
|
310
316
|
instance = self._build_cls(cls)
|
@@ -320,11 +326,14 @@ class CBV:
|
|
320
326
|
sign_cls_fn = partial(cls_fn)
|
321
327
|
update_wrapper(sign_cls_fn, cls_fn)
|
322
328
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
329
|
+
if has_cls_deps:
|
330
|
+
parameters, *_ = with_parameter(
|
331
|
+
sign_cls_fn,
|
332
|
+
name=collect_cls_dependencies.__name__,
|
333
|
+
default=Depends(collect_cls_dependencies),
|
334
|
+
)
|
335
|
+
else:
|
336
|
+
parameters = list_parameters(sign_cls_fn)
|
328
337
|
|
329
338
|
update_parameters(sign_cls_fn, *(parameters[1:]))
|
330
339
|
|
u_toolkit/signature.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import inspect
|
2
2
|
from collections.abc import Callable, Sequence
|
3
|
-
from functools import partial
|
4
3
|
from typing import Annotated, Any, overload
|
5
4
|
|
6
5
|
|
@@ -57,9 +56,9 @@ def update_signature(
|
|
57
56
|
return_annotation: type | None = None,
|
58
57
|
):
|
59
58
|
signature = inspect.signature(fn)
|
60
|
-
if parameters:
|
59
|
+
if parameters is not None:
|
61
60
|
signature = signature.replace(parameters=parameters)
|
62
|
-
if return_annotation:
|
61
|
+
if return_annotation is not None:
|
63
62
|
signature = signature.replace(return_annotation=return_annotation)
|
64
63
|
|
65
64
|
setattr(fn, "__signature__", signature)
|
@@ -9,9 +9,9 @@ u_toolkit/logger.py,sha256=NOmdR24QfSuo1EMnetyFioa8pA8OYceYTlQ4qiQcBdE,209
|
|
9
9
|
u_toolkit/merge.py,sha256=kHrloud-nPti5j48zkdvaiy4mIJYqOVguixAjWC46kE,924
|
10
10
|
u_toolkit/object.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
u_toolkit/path.py,sha256=IkyIHcU9hKBCOZfF30FrKf4CfL-MH91fjeYF9EY7eos,128
|
12
|
-
u_toolkit/signature.py,sha256
|
12
|
+
u_toolkit/signature.py,sha256=-Q6n28PYBYYdd2OXBKESeVkL2rYpV6EaY3IVwQmzezQ,2161
|
13
13
|
u_toolkit/fastapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
u_toolkit/fastapi/cbv.py,sha256=
|
14
|
+
u_toolkit/fastapi/cbv.py,sha256=gtNhV8mQAEQNf9uIwyjlrA-ZbVwLeJenJ-f2G2Co1SE,10808
|
15
15
|
u_toolkit/fastapi/config.py,sha256=kGpokR9XXr1KxMA1GVKYkCdKwqIQAIwOJ-v6sGbqzAQ,267
|
16
16
|
u_toolkit/fastapi/exception.py,sha256=5E4wAJYwp0RJ4SEBVkchOgrgfwCgniQ8Mtg1O5sWUXE,3288
|
17
17
|
u_toolkit/fastapi/helpers.py,sha256=BCMMLxa1c6BMA_rKq-hCi0iyEjrR3Z5rPMeTvgaVJB0,447
|
@@ -30,7 +30,7 @@ u_toolkit/sqlalchemy/type_vars.py,sha256=m2VeV41CBIK_1QX3w2kgz-n556sILAGZ-Kaz3TD
|
|
30
30
|
u_toolkit/sqlalchemy/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
31
|
u_toolkit/sqlalchemy/orm/fields.py,sha256=3zoYil23I6YLtc_59aHDt9w5l1NBTkePT9AfXI3DMiY,593
|
32
32
|
u_toolkit/sqlalchemy/orm/models.py,sha256=V8vf4ps3phAmwxyaFYK7pw8Igz7h097o4QBjKB0gwC8,705
|
33
|
-
u_toolkit-0.1.
|
34
|
-
u_toolkit-0.1.
|
35
|
-
u_toolkit-0.1.
|
36
|
-
u_toolkit-0.1.
|
33
|
+
u_toolkit-0.1.5.dist-info/METADATA,sha256=4JnI6t-zFqp7sGsXFTxSX_JvpnwspQVEmcXJ1PbHe_g,365
|
34
|
+
u_toolkit-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
35
|
+
u_toolkit-0.1.5.dist-info/entry_points.txt,sha256=hTfAYCd5vvRiqgnJk2eBsoRIiIVB9pK8WZm3Q3jjKFU,45
|
36
|
+
u_toolkit-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|