fastapi-extra 0.1.1__cp312-cp312-win_amd64.whl → 0.1.3__cp312-cp312-win_amd64.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.
- fastapi_extra/__init__.py +5 -3
- fastapi_extra/cursor.cp312-win_amd64.pyd +0 -0
- fastapi_extra/dependency.py +37 -0
- fastapi_extra/native/routing.pyx +6 -3
- fastapi_extra/routing.cp312-win_amd64.pyd +0 -0
- {fastapi_extra-0.1.1.dist-info → fastapi_extra-0.1.3.dist-info}/METADATA +12 -2
- fastapi_extra-0.1.3.dist-info/RECORD +16 -0
- {fastapi_extra-0.1.1.dist-info → fastapi_extra-0.1.3.dist-info}/WHEEL +1 -1
- fastapi_extra/service.py +0 -62
- fastapi_extra-0.1.1.dist-info/RECORD +0 -16
- {fastapi_extra-0.1.1.dist-info → fastapi_extra-0.1.3.dist-info}/LICENSE +0 -0
- {fastapi_extra-0.1.1.dist-info → fastapi_extra-0.1.3.dist-info}/top_level.txt +0 -0
fastapi_extra/__init__.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.3"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
from fastapi import FastAPI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def setup(app: FastAPI) -> None:
|
|
5
8
|
try:
|
|
6
9
|
from fastapi_extra import routing as native_routing # type: ignore
|
|
7
10
|
|
|
8
11
|
native_routing.install(app)
|
|
9
|
-
|
|
10
12
|
except ImportError: # pragma: nocover
|
|
11
13
|
pass
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
__author__ = "ziyan.yin"
|
|
2
|
+
__date__ = "2025-01-05"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
from abc import ABCMeta
|
|
6
|
+
from typing import Annotated, Any, Self
|
|
7
|
+
|
|
8
|
+
from fastapi.params import Depends
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AnnotationMetaClass(ABCMeta):
|
|
12
|
+
|
|
13
|
+
def __new__(
|
|
14
|
+
mcs,
|
|
15
|
+
name: str,
|
|
16
|
+
bases: tuple[type, ...],
|
|
17
|
+
attrs: dict,
|
|
18
|
+
annotated: bool = True
|
|
19
|
+
):
|
|
20
|
+
new_cls = super().__new__(mcs, name, bases, attrs)
|
|
21
|
+
if annotated:
|
|
22
|
+
return Annotated[new_cls, Depends(new_cls)]
|
|
23
|
+
return new_cls
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class AbstractDependency(metaclass=AnnotationMetaClass, annotated=False):
|
|
27
|
+
__slot__ = ()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AbstractWidget(AbstractDependency, annotated=False):
|
|
31
|
+
__slot__ = ()
|
|
32
|
+
__instance__: Any = None
|
|
33
|
+
|
|
34
|
+
def __new__(cls, *args, **kwargs) -> Self:
|
|
35
|
+
if cls.__instance__ is None:
|
|
36
|
+
cls.__instance__ = super().__new__(cls)
|
|
37
|
+
return cls.__instance__
|
fastapi_extra/native/routing.pyx
CHANGED
|
@@ -37,7 +37,7 @@ cdef list change_path_to_ranks(unicode path):
|
|
|
37
37
|
return ranks
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
cdef void add_route(unicode path,
|
|
40
|
+
cdef void add_route(unicode path, RouteNode root, object route):
|
|
41
41
|
current_node = root
|
|
42
42
|
ranks = change_path_to_ranks(path)
|
|
43
43
|
for r in ranks:
|
|
@@ -59,13 +59,15 @@ cdef list find_routes(unicode path, RouteNode root):
|
|
|
59
59
|
ranks = change_path_to_ranks(path)
|
|
60
60
|
|
|
61
61
|
routes = []
|
|
62
|
-
|
|
62
|
+
if current_node.routes:
|
|
63
|
+
routes += current_node.routes
|
|
63
64
|
for r in ranks:
|
|
64
65
|
if not r:
|
|
65
66
|
continue
|
|
66
67
|
if r in current_node.leaves:
|
|
67
68
|
current_node = current_node.leaves[r]
|
|
68
|
-
|
|
69
|
+
if current_node.routes:
|
|
70
|
+
routes += current_node.routes
|
|
69
71
|
continue
|
|
70
72
|
break
|
|
71
73
|
return routes
|
|
@@ -73,6 +75,7 @@ cdef list find_routes(unicode path, RouteNode root):
|
|
|
73
75
|
|
|
74
76
|
root_node = RouteNode.__new__(RouteNode, "")
|
|
75
77
|
|
|
78
|
+
|
|
76
79
|
async def handle(router, scope, receive, send):
|
|
77
80
|
assert scope["type"] in ("http", "websocket", "lifespan")
|
|
78
81
|
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: fastapi-extra
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: extra package for fastapi.
|
|
5
5
|
Author-email: Ziyan Yin <408856732@qq.com>
|
|
6
6
|
License: BSD-3-Clause
|
|
@@ -22,3 +22,13 @@ Requires-Dist: fastapi<0.116.0,>=0.115.0
|
|
|
22
22
|
Requires-Dist: httpx<0.29.0,>=0.28.0
|
|
23
23
|
Requires-Dist: pydantic-settings>=2.7.0
|
|
24
24
|
Requires-Dist: sqlmodel>=0.0.22
|
|
25
|
+
Provides-Extra: redis
|
|
26
|
+
Requires-Dist: redis; extra == "redis"
|
|
27
|
+
Provides-Extra: scheduler
|
|
28
|
+
Requires-Dist: apscheduler; extra == "scheduler"
|
|
29
|
+
Provides-Extra: mysql
|
|
30
|
+
Requires-Dist: asyncmy; extra == "mysql"
|
|
31
|
+
Provides-Extra: pgsql
|
|
32
|
+
Requires-Dist: asyncpg; extra == "pgsql"
|
|
33
|
+
Provides-Extra: aiomysql
|
|
34
|
+
Requires-Dist: aiomysql; extra == "aiomysql"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
fastapi_extra/__init__.py,sha256=YDEfRnc8WDitSi7nV_0AzTdZRG8Utju6bWJW3Ho0iBE,286
|
|
2
|
+
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=ovXk0tkV4Up8RdS4PEEgJAccITd8BDl6e2JETGA6FJw,57344
|
|
3
|
+
fastapi_extra/dependency.py,sha256=Pgl4Y9Mm6JY5pw19w_xJEmnnLkQ9p_K1h1w9lLVHUJQ,907
|
|
4
|
+
fastapi_extra/form.py,sha256=LikaJkA16dSRGCqX9K7z2S8-e3SJcMiVXX5nRZU_kVY,957
|
|
5
|
+
fastapi_extra/response.py,sha256=DHvhOSgwot5eBNKuI_jPYxZ5rshZ55Xkg-FNBJlHD1E,9609
|
|
6
|
+
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=5FzRt60laNI3hWONCZqWtMQUHPe6tReGNRQ-MXGX-hw,94720
|
|
7
|
+
fastapi_extra/settings.py,sha256=cCcwaper5GiNNoT4gNKqf-iloSOTNnMsiUR0knJx4Mw,1461
|
|
8
|
+
fastapi_extra/types.py,sha256=EUjT9jFryzlazHvWs4m-IfUezmSEvyxwaOGe_vTTBnY,763
|
|
9
|
+
fastapi_extra/utils.py,sha256=tsPX3kpF_P5D9Bd3gnlG6rkVsLkv5gbxjml-s6ZL_6I,346
|
|
10
|
+
fastapi_extra/native/cursor.pyx,sha256=bESprFDgk9gGjyPQ4YCSg51dov2WB6s60XrOs3r5-r0,1146
|
|
11
|
+
fastapi_extra/native/routing.pyx,sha256=GrdGAoBospwCpxMHBon5cuRYcz9ifAFSSYa2Ytf49lg,3841
|
|
12
|
+
fastapi_extra-0.1.3.dist-info/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
|
|
13
|
+
fastapi_extra-0.1.3.dist-info/METADATA,sha256=rrPhKMJTo4WWZgXOosqszSbTqXQFEUervKVwerZZE2A,1348
|
|
14
|
+
fastapi_extra-0.1.3.dist-info/WHEEL,sha256=cRmSBGD-cl98KkuHMNqv9Ac9L9_VqTvcBYwpIvxN0cg,101
|
|
15
|
+
fastapi_extra-0.1.3.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
|
|
16
|
+
fastapi_extra-0.1.3.dist-info/RECORD,,
|
fastapi_extra/service.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
__author__ = "ziyan.yin"
|
|
2
|
-
__date__ = "2025-01-05"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
from abc import ABCMeta
|
|
6
|
-
from typing import TYPE_CHECKING, Annotated, Any, Self, Type, TypeVar
|
|
7
|
-
|
|
8
|
-
from fastapi.params import Depends
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class ServiceMetaClass(ABCMeta):
|
|
12
|
-
__root__: Any = None
|
|
13
|
-
|
|
14
|
-
def __new__(
|
|
15
|
-
mcs,
|
|
16
|
-
name: str,
|
|
17
|
-
bases: tuple[type, ...],
|
|
18
|
-
attrs: dict,
|
|
19
|
-
abstract: bool = False
|
|
20
|
-
):
|
|
21
|
-
new_cls = super().__new__(mcs, name, bases, attrs)
|
|
22
|
-
|
|
23
|
-
if not abstract:
|
|
24
|
-
if new_cls.__root__ and issubclass(new_cls, new_cls.__root__.__class__):
|
|
25
|
-
base_cls = new_cls.__root__.__class__
|
|
26
|
-
new_cls.__root__ = None
|
|
27
|
-
new_cls.__root__ = new_cls()
|
|
28
|
-
base_cls.__root__ = new_cls.__root__
|
|
29
|
-
else:
|
|
30
|
-
new_cls.__root__ = None
|
|
31
|
-
new_cls.__root__ = new_cls()
|
|
32
|
-
|
|
33
|
-
return new_cls
|
|
34
|
-
|
|
35
|
-
def __call__(cls, *args, **kwargs):
|
|
36
|
-
if cls.__root__ is not None:
|
|
37
|
-
return cls.__root__
|
|
38
|
-
return super().__call__(*args, **kwargs)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
class IService(metaclass=ServiceMetaClass, abstract=True):
|
|
42
|
-
|
|
43
|
-
def _load(self, *args, **kwargs) -> Self:
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
S = TypeVar("S", bound=IService)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class Service_:
|
|
51
|
-
|
|
52
|
-
@classmethod
|
|
53
|
-
def __class_getitem__(cls, item: Type[IService]):
|
|
54
|
-
if not item.__root__:
|
|
55
|
-
raise ImportError(cls.__name__)
|
|
56
|
-
return Annotated[item, Depends(item.__root__._load)]
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if TYPE_CHECKING:
|
|
60
|
-
Service = Annotated[S, None]
|
|
61
|
-
else:
|
|
62
|
-
Service = Service_
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
fastapi_extra/__init__.py,sha256=tTJRKJzL6en03Hfkvn8Up7zDesLA7TiwVqMtuML14Bw,248
|
|
2
|
-
fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=WNCo9TTvn9_vOsac6kwn2h7WBWjEnpJ4gSBwwIdILhc,57344
|
|
3
|
-
fastapi_extra/form.py,sha256=LikaJkA16dSRGCqX9K7z2S8-e3SJcMiVXX5nRZU_kVY,957
|
|
4
|
-
fastapi_extra/response.py,sha256=DHvhOSgwot5eBNKuI_jPYxZ5rshZ55Xkg-FNBJlHD1E,9609
|
|
5
|
-
fastapi_extra/routing.cp312-win_amd64.pyd,sha256=LkBB0FYt7BxNmjwVEI_TLg4x1rUY4NtZkUkFbBhoMlg,94208
|
|
6
|
-
fastapi_extra/service.py,sha256=-W_noWPQHaKP4ZMnhM4Ub0eHD6bkxO0-q8FKP2GW2SU,1596
|
|
7
|
-
fastapi_extra/settings.py,sha256=cCcwaper5GiNNoT4gNKqf-iloSOTNnMsiUR0knJx4Mw,1461
|
|
8
|
-
fastapi_extra/types.py,sha256=EUjT9jFryzlazHvWs4m-IfUezmSEvyxwaOGe_vTTBnY,763
|
|
9
|
-
fastapi_extra/utils.py,sha256=tsPX3kpF_P5D9Bd3gnlG6rkVsLkv5gbxjml-s6ZL_6I,346
|
|
10
|
-
fastapi_extra/native/cursor.pyx,sha256=bESprFDgk9gGjyPQ4YCSg51dov2WB6s60XrOs3r5-r0,1146
|
|
11
|
-
fastapi_extra/native/routing.pyx,sha256=sByKvUrILFKkEky2nhlzA4vLJsmvk1B2cZs0s2yH1g0,3762
|
|
12
|
-
fastapi_extra-0.1.1.dist-info/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
|
|
13
|
-
fastapi_extra-0.1.1.dist-info/METADATA,sha256=fOB5ieSAxzIAl94sypb8E-WZxmTPtH3XzKGv_n2qYbA,1006
|
|
14
|
-
fastapi_extra-0.1.1.dist-info/WHEEL,sha256=pWXrJbnZSH-J-PhYmKs2XNn4DHCPNBYq965vsBJBFvA,101
|
|
15
|
-
fastapi_extra-0.1.1.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
|
|
16
|
-
fastapi_extra-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|