fastapi-voyager 0.6.1__py3-none-any.whl → 0.6.2__py3-none-any.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_voyager/type_helper.py +23 -2
- fastapi_voyager/version.py +1 -1
- {fastapi_voyager-0.6.1.dist-info → fastapi_voyager-0.6.2.dist-info}/METADATA +8 -8
- {fastapi_voyager-0.6.1.dist-info → fastapi_voyager-0.6.2.dist-info}/RECORD +7 -7
- {fastapi_voyager-0.6.1.dist-info → fastapi_voyager-0.6.2.dist-info}/WHEEL +0 -0
- {fastapi_voyager-0.6.1.dist-info → fastapi_voyager-0.6.2.dist-info}/entry_points.txt +0 -0
- {fastapi_voyager-0.6.1.dist-info → fastapi_voyager-0.6.2.dist-info}/licenses/LICENSE +0 -0
fastapi_voyager/type_helper.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import os
|
|
3
3
|
from pydantic import BaseModel
|
|
4
|
-
from typing import get_origin, get_args, Union, Annotated, Any, Type
|
|
4
|
+
from typing import get_origin, get_args, Union, Annotated, Any, Type, Generic
|
|
5
5
|
from fastapi_voyager.type import FieldInfo
|
|
6
6
|
from types import UnionType
|
|
7
7
|
import pydantic_resolve.constant as const
|
|
@@ -142,7 +142,7 @@ def get_type_name(anno):
|
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
def is_inheritance_of_pydantic_base(cls):
|
|
145
|
-
return safe_issubclass(cls, BaseModel) and cls is not BaseModel
|
|
145
|
+
return safe_issubclass(cls, BaseModel) and cls is not BaseModel and not is_generic_container(cls)
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
def get_bases_fields(schemas: list[type[BaseModel]]) -> set[str]:
|
|
@@ -256,6 +256,27 @@ def update_forward_refs(kls):
|
|
|
256
256
|
if safe_issubclass(shelled_type, BaseModel):
|
|
257
257
|
update_pydantic_forward_refs(shelled_type)
|
|
258
258
|
|
|
259
|
+
|
|
260
|
+
def is_generic_container(cls):
|
|
261
|
+
"""
|
|
262
|
+
T = TypeVar('T')
|
|
263
|
+
class DataModel(BaseModel, Generic[T]):
|
|
264
|
+
data: T
|
|
265
|
+
id: int
|
|
266
|
+
|
|
267
|
+
type DataModelPageStory = DataModel[PageStory]
|
|
268
|
+
|
|
269
|
+
is_generic_container(DataModel) -> True
|
|
270
|
+
is_generic_container(DataModel[PageStory]) -> False
|
|
271
|
+
|
|
272
|
+
DataModel.__parameters__ == (T,)
|
|
273
|
+
DataModelPageStory.__parameters__ == (,)
|
|
274
|
+
"""
|
|
275
|
+
try:
|
|
276
|
+
return (hasattr(cls, '__bases__') and Generic in cls.__bases__ and (hasattr(cls, '__parameters__') and bool(cls.__parameters__)))
|
|
277
|
+
except (TypeError, AttributeError):
|
|
278
|
+
return False
|
|
279
|
+
|
|
259
280
|
if __name__ == "__main__":
|
|
260
281
|
from tests.demo_anno import PageSprint, PageOverall
|
|
261
282
|
|
fastapi_voyager/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
__all__ = ["__version__"]
|
|
2
|
-
__version__ = "0.6.
|
|
2
|
+
__version__ = "0.6.2"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-voyager
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Visualize FastAPI application's routing tree and dependencies
|
|
5
5
|
Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
|
|
6
6
|
Project-URL: Source, https://github.com/allmonday/fastapi-voyager
|
|
@@ -183,13 +183,7 @@ features
|
|
|
183
183
|
- [ ] abstract render module
|
|
184
184
|
- [ ] export voyager core data into json (for better debugging)
|
|
185
185
|
- [ ] add api to rebuild core data from json, and render it
|
|
186
|
-
- [
|
|
187
|
-
|
|
188
|
-
```python
|
|
189
|
-
class Paged(BaseModel, Generic[T]):
|
|
190
|
-
total: int
|
|
191
|
-
items: List[T]
|
|
192
|
-
```
|
|
186
|
+
- [x] fix Generic case `test_generic.py`
|
|
193
187
|
|
|
194
188
|
bugs:
|
|
195
189
|
- [ ] fix duplicated link from class and parent class, it also break clicking highlight
|
|
@@ -205,3 +199,9 @@ TODO: ...
|
|
|
205
199
|
|
|
206
200
|
- https://apis.guru/graphql-voyager/, for inspiration.
|
|
207
201
|
- https://github.com/tintinweb/vscode-interactive-graphviz, for web visualization.
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
## Changelog
|
|
205
|
+
|
|
206
|
+
- 0.6.2:
|
|
207
|
+
- fix generic related issue
|
|
@@ -5,8 +5,8 @@ fastapi_voyager/module.py,sha256=Z2QHNmiLk6ZAJlm2nSmO875Q33TweSg8UxZSzIpU9zY,349
|
|
|
5
5
|
fastapi_voyager/render.py,sha256=ctwad-KNbFajhgnA8OI8412s6s67UbV-dvZFXBt_Ssg,7410
|
|
6
6
|
fastapi_voyager/server.py,sha256=6pDFrVd4AZP3KaqukJS7xq_f7ar4gLkb6XhSO5zoW_A,3782
|
|
7
7
|
fastapi_voyager/type.py,sha256=nad4WNxTcZFi7Mskw6p2W7v2Gs4f0giVLNoFjZlKmbA,1778
|
|
8
|
-
fastapi_voyager/type_helper.py,sha256=
|
|
9
|
-
fastapi_voyager/version.py,sha256=
|
|
8
|
+
fastapi_voyager/type_helper.py,sha256=f2Gy5r3Zi6a2wTkbqU9W-AkvcetajEYCfroACzcIcVY,9064
|
|
9
|
+
fastapi_voyager/version.py,sha256=esNfySzRU9jKScInt96qMV6-yrFqc5OFPWfMqNLhEWE,48
|
|
10
10
|
fastapi_voyager/voyager.py,sha256=qMXZrQsmUiBljhOFOUtXV--a5i7THz9l00UNoxDu_0w,10193
|
|
11
11
|
fastapi_voyager/web/graph-ui.js,sha256=eEjDnJVMvk35LdRoxcqX_fZxLFS9_bUrGAZL6K2O5C0,4176
|
|
12
12
|
fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
|
|
@@ -26,8 +26,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
|
|
|
26
26
|
fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
|
|
27
27
|
fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
|
|
28
28
|
fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
|
|
29
|
-
fastapi_voyager-0.6.
|
|
30
|
-
fastapi_voyager-0.6.
|
|
31
|
-
fastapi_voyager-0.6.
|
|
32
|
-
fastapi_voyager-0.6.
|
|
33
|
-
fastapi_voyager-0.6.
|
|
29
|
+
fastapi_voyager-0.6.2.dist-info/METADATA,sha256=LGxHZaMAoK5qMgAJiWZTM4ukoDrrndj4R3NUKsygzko,6866
|
|
30
|
+
fastapi_voyager-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
31
|
+
fastapi_voyager-0.6.2.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
|
|
32
|
+
fastapi_voyager-0.6.2.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
|
|
33
|
+
fastapi_voyager-0.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|