u-toolkit 0.1.3__tar.gz → 0.1.4__tar.gz
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-0.1.3 → u_toolkit-0.1.4}/PKG-INFO +1 -1
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/pyproject.toml +1 -1
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/cbv.py +17 -5
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/tests/fastapi/test_cbv.py +13 -6
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/.github/workflows/publish.yml +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/.gitignore +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/README.md +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/alias_generators.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/datetime.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/decorators.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/enum.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/config.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/exception.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/helpers.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/lifespan.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/pagination.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/fastapi/responses.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/function.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/helpers.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/logger.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/merge.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/object.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/path.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/pydantic/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/pydantic/fields.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/pydantic/models.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/pydantic/type_vars.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/signature.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/fields.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/function.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/orm/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/orm/fields.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/orm/models.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/table_info.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/src/u_toolkit/sqlalchemy/type_vars.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/tests/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/tests/fastapi/__init__.py +0 -0
- {u_toolkit-0.1.3 → u_toolkit-0.1.4}/uv.lock +0 -0
@@ -306,6 +306,13 @@ class CBV:
|
|
306
306
|
|
307
307
|
update_parameters(collect_cls_dependencies, *parameters)
|
308
308
|
|
309
|
+
def new_fn(method_name, kwargs):
|
310
|
+
instance = self._build_cls(cls)
|
311
|
+
dependencies = kwargs.pop(collect_cls_dependencies.__name__)
|
312
|
+
for dep_name, dep_value in dependencies.items():
|
313
|
+
setattr(instance, dep_name, dep_value)
|
314
|
+
return getattr(instance, method_name)
|
315
|
+
|
309
316
|
def decorator(method: Callable):
|
310
317
|
method_name = method.__name__
|
311
318
|
|
@@ -321,13 +328,18 @@ class CBV:
|
|
321
328
|
|
322
329
|
update_parameters(sign_cls_fn, *(parameters[1:]))
|
323
330
|
|
331
|
+
if inspect.iscoroutinefunction(method):
|
332
|
+
|
333
|
+
@wraps(sign_cls_fn)
|
334
|
+
async def awrapper(*args, **kwargs):
|
335
|
+
fn = new_fn(method_name, kwargs)
|
336
|
+
return await fn(*args, **kwargs)
|
337
|
+
|
338
|
+
return awrapper
|
339
|
+
|
324
340
|
@wraps(sign_cls_fn)
|
325
341
|
def wrapper(*args, **kwargs):
|
326
|
-
|
327
|
-
dependencies = kwargs.pop(collect_cls_dependencies.__name__)
|
328
|
-
for dep_name, dep_value in dependencies.items():
|
329
|
-
setattr(instance, dep_name, dep_value)
|
330
|
-
fn = getattr(instance, method_name)
|
342
|
+
fn = new_fn(method_name, kwargs)
|
331
343
|
return fn(*args, **kwargs)
|
332
344
|
|
333
345
|
return wrapper
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import asyncio
|
1
2
|
from typing import Annotated, cast
|
2
3
|
|
3
4
|
import sqlalchemy as sa
|
@@ -56,17 +57,21 @@ class R:
|
|
56
57
|
def get(self):
|
57
58
|
return self.value, self.value2, self.value3
|
58
59
|
|
59
|
-
@cbv.info(status=status.HTTP_201_CREATED)
|
60
|
-
def post(self):
|
61
|
-
record = self.db_dep.execute(sa.text(f"select '{RESULT}'")).one()
|
62
|
-
return record[0]
|
63
|
-
|
64
60
|
def get__wtf____(self):
|
65
61
|
pass
|
66
62
|
|
67
63
|
@cbv.info(path="/lalala")
|
68
64
|
def get_custom(self): ...
|
69
65
|
|
66
|
+
async def get_async_value(self):
|
67
|
+
await asyncio.sleep(0.001)
|
68
|
+
return 1
|
69
|
+
|
70
|
+
@cbv.info(status=status.HTTP_201_CREATED)
|
71
|
+
def post(self):
|
72
|
+
record = self.db_dep.execute(sa.text(f"select '{RESULT}'")).one()
|
73
|
+
return record[0]
|
74
|
+
|
70
75
|
|
71
76
|
@cbv
|
72
77
|
class _NoPath:
|
@@ -85,7 +90,9 @@ client = TestClient(app)
|
|
85
90
|
|
86
91
|
def test_cbv():
|
87
92
|
assert client.get("/r").json() == [dep1_value, dep2_value, dep3_value]
|
88
|
-
assert client.get("/
|
93
|
+
assert client.get("/r/_wtf//").is_success
|
94
|
+
assert client.get("/lalala").is_success
|
95
|
+
assert client.get("/r/async_value").json() == 1
|
89
96
|
|
90
97
|
post_resp = client.post("/r")
|
91
98
|
assert post_resp.status_code == status.HTTP_201_CREATED
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|