fastapi-extra 0.1.1__cp312-cp312-win_amd64.whl → 0.1.2__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,11 +1,15 @@
1
- __version__ = "0.1.1"
1
+ __version__ = "0.1.2"
2
2
 
3
3
 
4
- def install(app) -> None:
4
+ from fastapi import FastAPI
5
+
6
+
7
+ def install(app: FastAPI) -> None:
5
8
  try:
6
9
  from fastapi_extra import routing as native_routing # type: ignore
10
+ from fastapi_extra import dependency
7
11
 
8
12
  native_routing.install(app)
9
-
13
+ app.dependency_overrides |= dependency.default_dependency_override
10
14
  except ImportError: # pragma: nocover
11
15
  pass
Binary file
@@ -0,0 +1,38 @@
1
+ __author__ = "ziyan.yin"
2
+ __date__ = "2025-01-05"
3
+
4
+
5
+ from abc import ABCMeta
6
+ from typing import Annotated, Any
7
+
8
+ from fastapi.params import Depends
9
+
10
+
11
+ default_dependency_override = {}
12
+
13
+
14
+ class DependencyMetaClass(ABCMeta):
15
+ __root__: Any = None
16
+
17
+ def __new__(
18
+ mcs,
19
+ name: str,
20
+ bases: tuple[type, ...],
21
+ attrs: dict,
22
+ root: bool = False,
23
+ override: bool = False
24
+ ):
25
+ 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
31
+ return Annotated[new_cls, Depends(new_cls)]
32
+ return new_cls
33
+
34
+
35
+
36
+ class Service(metaclass=DependencyMetaClass, root=True):
37
+ __slot__ = ()
38
+
fastapi_extra/form.py CHANGED
@@ -28,3 +28,8 @@ 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="密码")
Binary file
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: fastapi-extra
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: extra package for fastapi.
5
5
  Author-email: Ziyan Yin <408856732@qq.com>
6
6
  License: BSD-3-Clause
@@ -0,0 +1,16 @@
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5
 
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,,