fastapi-extra 0.5.0__tar.gz → 0.6.0__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.
Files changed (32) hide show
  1. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/PKG-INFO +3 -1
  2. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/__init__.py +1 -1
  3. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/database/model.py +2 -2
  4. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/database/service.py +7 -3
  5. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/response.py +10 -6
  6. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra.egg-info/PKG-INFO +3 -1
  7. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra.egg-info/requires.txt +3 -0
  8. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/pyproject.toml +1 -0
  9. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/LICENSE +0 -0
  10. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/README.rst +0 -0
  11. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/_patch.py +0 -0
  12. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/cache/__init__.py +0 -0
  13. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/cache/redis.py +0 -0
  14. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/cursor.pyi +0 -0
  15. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/database/__init__.py +0 -0
  16. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/database/session.py +0 -0
  17. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/database/sqlmap.py +0 -0
  18. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/dependency.py +0 -0
  19. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/form.py +0 -0
  20. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/native/cursor.pyx +0 -0
  21. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/native/routing.pyx +0 -0
  22. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/native/urlparse.pyx +0 -0
  23. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/py.typed +0 -0
  24. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/routing.pyi +0 -0
  25. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/settings.py +0 -0
  26. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/types.py +0 -0
  27. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/urlparse.pyi +0 -0
  28. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra/utils.py +0 -0
  29. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra.egg-info/SOURCES.txt +0 -0
  30. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra.egg-info/dependency_links.txt +0 -0
  31. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/fastapi_extra.egg-info/top_level.txt +0 -0
  32. {fastapi_extra-0.5.0 → fastapi_extra-0.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-extra
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: extra package for fastapi.
5
5
  Author-email: Ziyan Yin <408856732@qq.com>
6
6
  License: BSD-3-Clause
@@ -30,6 +30,8 @@ Provides-Extra: mysql
30
30
  Requires-Dist: asyncmy; extra == "mysql"
31
31
  Provides-Extra: pgsql
32
32
  Requires-Dist: asyncpg; extra == "pgsql"
33
+ Provides-Extra: oracle
34
+ Requires-Dist: python-oracledb; extra == "oracle"
33
35
  Provides-Extra: aiomysql
34
36
  Requires-Dist: aiomysql; extra == "aiomysql"
35
37
  Dynamic: license-file
@@ -1,4 +1,4 @@
1
- __version__ = "0.5.0"
1
+ __version__ = "0.6.0"
2
2
 
3
3
 
4
4
  from fastapi import FastAPI
@@ -14,7 +14,7 @@ from fastapi_extra.utils import get_machine_seed
14
14
 
15
15
 
16
16
  class AutoPK(SQLModel):
17
- id: int | None = Field(
17
+ id: int = Field(
18
18
  default=None,
19
19
  title="ID",
20
20
  primary_key=True,
@@ -25,7 +25,7 @@ class AutoPK(SQLModel):
25
25
 
26
26
 
27
27
  class LocalPK(SQLModel):
28
- id: Cursor | None = Field(
28
+ id: Cursor = Field(
29
29
  default_factory=_Cursor(get_machine_seed()).next_val,
30
30
  title="ID",
31
31
  primary_key=True,
@@ -1,6 +1,7 @@
1
1
  __author__ = "ziyan.yin"
2
2
  __date__ = "2025-01-12"
3
3
 
4
+
4
5
  from contextvars import ContextVar
5
6
  from typing import Any, Generic, Sequence, TypeVar
6
7
 
@@ -57,10 +58,13 @@ class ModelService(AbstractService, Generic[Model], abstract=True):
57
58
  await self.session.flush()
58
59
  return model
59
60
 
60
- async def update_model(self, model: Model, **kwargs: Any) -> Model:
61
+ async def update_model(self, model: Model, _ignore_none: bool = True, **kwargs: Any) -> Model:
61
62
  for key, value in kwargs.items():
62
- if key in model.__fields__:
63
- setattr(model, key, value)
63
+ if key not in model.__fields__:
64
+ continue
65
+ if _ignore_none and value is None:
66
+ continue
67
+ setattr(model, key, value)
64
68
  await self.session.flush()
65
69
  return model
66
70
 
@@ -3,7 +3,8 @@ __date__ = "2024-12-24"
3
3
 
4
4
 
5
5
  from enum import Enum
6
- from typing import TYPE_CHECKING, Generic, Mapping
6
+ from typing import (TYPE_CHECKING, Generic, Mapping, NotRequired, TypedDict,
7
+ Unpack)
7
8
 
8
9
  from fastapi.responses import JSONResponse
9
10
  from pydantic import BaseModel, Field
@@ -191,22 +192,25 @@ class ResultEnum(Enum):
191
192
  C0503 = ("C0503", "邮件提醒服务失败")
192
193
 
193
194
 
195
+ class ResponseKwargs(TypedDict):
196
+ status_code: NotRequired[int]
197
+ headers: NotRequired[Mapping[str, str] | None]
198
+
199
+
194
200
  class APIResult(BaseModel, Generic[T]):
195
201
  data: T | None = Field(default=None, title="返回数据")
196
202
 
197
203
  if TYPE_CHECKING:
198
-
199
204
  @classmethod
200
- def ok(cls, data: T | None = None) -> "APIResult[T]":
205
+ def ok(cls, data: T | None = None, **response_kwargs: Unpack[ResponseKwargs]) -> "APIResult[T]":
201
206
  return APIResult(data=data)
202
207
 
203
208
  else:
204
-
205
209
  @classmethod
206
- def ok(cls, data: T | None = None) -> "APIResponse":
210
+ def ok(cls, data: T | None = None, status_code: int = 200, headers: Mapping[str, str] | None = None) -> "APIResponse":
207
211
  model = cls.__new__(cls)
208
212
  model.__dict__["data"] = data
209
- return APIResponse(model)
213
+ return APIResponse(model, status_code=status_code, headers=headers)
210
214
 
211
215
 
212
216
  class APIResponse(JSONResponse):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-extra
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: extra package for fastapi.
5
5
  Author-email: Ziyan Yin <408856732@qq.com>
6
6
  License: BSD-3-Clause
@@ -30,6 +30,8 @@ Provides-Extra: mysql
30
30
  Requires-Dist: asyncmy; extra == "mysql"
31
31
  Provides-Extra: pgsql
32
32
  Requires-Dist: asyncpg; extra == "pgsql"
33
+ Provides-Extra: oracle
34
+ Requires-Dist: python-oracledb; extra == "oracle"
33
35
  Provides-Extra: aiomysql
34
36
  Requires-Dist: aiomysql; extra == "aiomysql"
35
37
  Dynamic: license-file
@@ -9,6 +9,9 @@ aiomysql
9
9
  [mysql]
10
10
  asyncmy
11
11
 
12
+ [oracle]
13
+ python-oracledb
14
+
12
15
  [pgsql]
13
16
  asyncpg
14
17
 
@@ -41,6 +41,7 @@ redis = ["redis"]
41
41
  scheduler = ["apscheduler"]
42
42
  mysql = ["asyncmy"]
43
43
  pgsql = ["asyncpg"]
44
+ oracle = ["python-oracledb"]
44
45
  aiomysql = ["aiomysql"]
45
46
 
46
47
  [tool.setuptools]
File without changes
File without changes
File without changes