fastapi-extra 0.1.2__cp312-cp312-win_amd64.whl → 0.1.4__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 CHANGED
@@ -1,15 +1,13 @@
1
- __version__ = "0.1.2"
1
+ __version__ = "0.1.4"
2
2
 
3
3
 
4
4
  from fastapi import FastAPI
5
5
 
6
6
 
7
- def install(app: FastAPI) -> None:
7
+ def setup(app: FastAPI) -> None:
8
8
  try:
9
9
  from fastapi_extra import routing as native_routing # type: ignore
10
- from fastapi_extra import dependency
11
10
 
12
11
  native_routing.install(app)
13
- app.dependency_overrides |= dependency.default_dependency_override
14
12
  except ImportError: # pragma: nocover
15
13
  pass
Binary file
@@ -3,36 +3,35 @@ __date__ = "2025-01-05"
3
3
 
4
4
 
5
5
  from abc import ABCMeta
6
- from typing import Annotated, Any
6
+ from typing import Annotated, Any, Self
7
7
 
8
8
  from fastapi.params import Depends
9
9
 
10
10
 
11
- default_dependency_override = {}
12
-
13
-
14
- class DependencyMetaClass(ABCMeta):
15
- __root__: Any = None
11
+ class AnnotationMetaClass(ABCMeta):
16
12
 
17
13
  def __new__(
18
14
  mcs,
19
15
  name: str,
20
16
  bases: tuple[type, ...],
21
17
  attrs: dict,
22
- root: bool = False,
23
- override: bool = False
18
+ annotated: bool = True
24
19
  ):
25
20
  new_cls = super().__new__(mcs, name, bases, attrs)
26
- if not root:
27
- if new_cls.__root__ is None:
28
- new_cls.__root__ = new_cls
29
- elif override:
30
- default_dependency_override[new_cls.__root__] = new_cls
21
+ if annotated:
31
22
  return Annotated[new_cls, Depends(new_cls)]
32
23
  return new_cls
33
24
 
34
25
 
26
+ class AbstractDependency(metaclass=AnnotationMetaClass, annotated=False):
27
+ __slot__ = ()
35
28
 
36
- class Service(metaclass=DependencyMetaClass, root=True):
29
+
30
+ class AbstractWidget(AbstractDependency, annotated=False):
37
31
  __slot__ = ()
38
-
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/form.py CHANGED
@@ -28,8 +28,3 @@ class ColumnExpression(BaseModel, Generic[S]):
28
28
  class WhereClause(BaseModel):
29
29
  option: Literal["and", "or"] = Field(default="and", title="关系")
30
30
  column_clauses: list[ColumnExpression | "WhereClause"]
31
-
32
-
33
- class LoginForm(BaseModel):
34
- username: str = Field(title="用户名")
35
- password: str = Field(title="密码")
@@ -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, object root, object route):
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
- routes += current_node.routes
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
- routes += current_node.routes
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
1
  Metadata-Version: 2.2
2
2
  Name: fastapi-extra
3
- Version: 0.1.2
3
+ Version: 0.1.4
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=wZGS0_cF9HspqetdvcDTIxjV9lp-0yTS7toLQQnJI0Q,286
2
+ fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=Zj_hwMRczIkzNkXjW3dUeNqrpBXW-hcTyNPlHSYxW9s,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=4Vlhy3oYaYhUzj9jxQuONzlLYjfo03OmTsCg8jUUbcQ,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.4.dist-info/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
13
+ fastapi_extra-0.1.4.dist-info/METADATA,sha256=2YlZPZ_9Y8rbBVG2th19mmT12zzXuBTt7MQDsRtgIjo,1348
14
+ fastapi_extra-0.1.4.dist-info/WHEEL,sha256=cRmSBGD-cl98KkuHMNqv9Ac9L9_VqTvcBYwpIvxN0cg,101
15
+ fastapi_extra-0.1.4.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
16
+ fastapi_extra-0.1.4.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- fastapi_extra/__init__.py,sha256=Q--tEaIQ892MOwYjKzWvrpUD2H3srBTbCBDRDBAFRqE,410
2
- fastapi_extra/cursor.cp312-win_amd64.pyd,sha256=g21HsiTvEovTioMgGGC9VKnMRhtTH6qOOOxCh7w9ffg,57344
3
- fastapi_extra/dependency.py,sha256=fs-WUmYImz8UUGC2LkOxn_3w1H_iVA4dVha8oiz6hKA,878
4
- fastapi_extra/form.py,sha256=h6xaWF8sjnD4uinBRWnFbgWgaxerYjzUAROXQiXyFBk,1079
5
- fastapi_extra/response.py,sha256=DHvhOSgwot5eBNKuI_jPYxZ5rshZ55Xkg-FNBJlHD1E,9609
6
- fastapi_extra/routing.cp312-win_amd64.pyd,sha256=14ZPwBtxTMT2rHqp9sGq3vxDsfCO5O9geq8QlTdL1lI,94208
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.2.dist-info/LICENSE,sha256=0vTjHDa3VDsxTT-R-sH6SpYcA2F1hKtbX9ZFZQm-EcU,1516
13
- fastapi_extra-0.1.2.dist-info/METADATA,sha256=aSjC76xJbexcUAHmFUPFabhn11xEaBcYkW5pK-mNwVI,1006
14
- fastapi_extra-0.1.2.dist-info/WHEEL,sha256=cRmSBGD-cl98KkuHMNqv9Ac9L9_VqTvcBYwpIvxN0cg,101
15
- fastapi_extra-0.1.2.dist-info/top_level.txt,sha256=B7D80bEftE2E-eSd1be2r9BWkLLMZN21dRTWpb4y4Ig,14
16
- fastapi_extra-0.1.2.dist-info/RECORD,,