fastapi-deferred-init 0.3.0__tar.gz → 0.3.1__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.
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/PKG-INFO +2 -2
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/pyproject.toml +7 -7
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/patch.py +5 -1
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/routing.py +4 -2
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/test_lib.py +3 -5
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/LICENSE +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/README.md +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/__init__.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/py.typed +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/__init__.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/conftest.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/data/__init__.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/data/gen_code_ast.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/data/template.py +0 -0
- {fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/tests/helpers.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fastapi-deferred-init
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Faster FastAPI start-up time for Projects with many nested routers
|
|
5
5
|
Keywords: fastapi,speed,router,startup,optimization
|
|
6
6
|
Author-Email: Jan Vollmer <jan@vllmr.dev>
|
|
@@ -18,7 +18,7 @@ Classifier: Typing :: Typed
|
|
|
18
18
|
Project-URL: Source, https://github.com/jvllmr/fastapi-deferred-init
|
|
19
19
|
Project-URL: Changelog, https://github.com/jvllmr/fastapi-deferred-init/releases
|
|
20
20
|
Requires-Python: >=3.10
|
|
21
|
-
Requires-Dist: fastapi>=0.
|
|
21
|
+
Requires-Dist: fastapi>=0.139.0
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
|
|
24
24
|
# fastapi-deferred-init
|
|
@@ -12,7 +12,7 @@ authors = [
|
|
|
12
12
|
{ name = "Jan Vollmer", email = "jan@vllmr.dev" },
|
|
13
13
|
]
|
|
14
14
|
dependencies = [
|
|
15
|
-
"fastapi>=0.
|
|
15
|
+
"fastapi>=0.139.0",
|
|
16
16
|
]
|
|
17
17
|
requires-python = ">=3.10"
|
|
18
18
|
readme = "README.md"
|
|
@@ -29,7 +29,7 @@ classifiers = [
|
|
|
29
29
|
"Typing :: Typed",
|
|
30
30
|
]
|
|
31
31
|
dynamic = []
|
|
32
|
-
version = "0.3.
|
|
32
|
+
version = "0.3.1"
|
|
33
33
|
|
|
34
34
|
[project.license]
|
|
35
35
|
text = "MIT"
|
|
@@ -85,13 +85,13 @@ all = true
|
|
|
85
85
|
|
|
86
86
|
[dependency-groups]
|
|
87
87
|
dev = [
|
|
88
|
-
"pytest>=9.1.
|
|
89
|
-
"ruff>=0.15.
|
|
88
|
+
"pytest>=9.1.1",
|
|
89
|
+
"ruff>=0.15.20",
|
|
90
90
|
"pre-commit>=4.3.0",
|
|
91
|
-
"mypy>=1.
|
|
91
|
+
"mypy>=2.1.0",
|
|
92
92
|
"tuna>=0.5.15",
|
|
93
|
-
"httpx>=0.28.1",
|
|
94
93
|
"pytest-benchmark>=5.2.3",
|
|
95
94
|
"pip>=26.1.2",
|
|
96
|
-
"inline-snapshot>=0.34.
|
|
95
|
+
"inline-snapshot>=0.34.2",
|
|
96
|
+
"httpx2>=2.9.1",
|
|
97
97
|
]
|
{fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/patch.py
RENAMED
|
@@ -7,4 +7,8 @@ def apply_patch() -> None:
|
|
|
7
7
|
|
|
8
8
|
routing._populate_api_route_state = _populate_api_route_state # ty:ignore[invalid-assignment]
|
|
9
9
|
routing.APIRoute = DeferringAPIRoute # ty:ignore[invalid-assignment]
|
|
10
|
-
routing.APIRouter = DeferringAPIRouter
|
|
10
|
+
routing.APIRouter = DeferringAPIRouter # ty:ignore[invalid-assignment]
|
|
11
|
+
|
|
12
|
+
import fastapi
|
|
13
|
+
|
|
14
|
+
fastapi.APIRouter = DeferringAPIRouter # type:ignore[attr-defined] # ty:ignore[invalid-assignment]
|
{fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/routing.py
RENAMED
|
@@ -35,11 +35,13 @@ def _add_cache_attribute(
|
|
|
35
35
|
instance: routing._APIRouteLike, name: str, func: Callable[[Any], Any]
|
|
36
36
|
) -> None:
|
|
37
37
|
cls = type(instance)
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
if name in instance.__dict__ and (
|
|
40
|
+
(val := instance.__dict__[name]) is None or val is False
|
|
40
41
|
):
|
|
41
42
|
delattr(instance, name)
|
|
42
43
|
|
|
44
|
+
# replace attribute with cached_property
|
|
43
45
|
if not hasattr(cls, name) or not isinstance(getattr(cls, name), cached_property):
|
|
44
46
|
prop = cached_property(func)
|
|
45
47
|
setattr(cls, name, prop)
|
|
@@ -3,7 +3,7 @@ import os
|
|
|
3
3
|
import pytest
|
|
4
4
|
from pydantic import BaseModel
|
|
5
5
|
|
|
6
|
-
from fastapi import FastAPI
|
|
6
|
+
from fastapi import FastAPI, APIRouter
|
|
7
7
|
from fastapi import routing
|
|
8
8
|
from fastapi.testclient import TestClient
|
|
9
9
|
from fastapi_deferred_init.routing import (
|
|
@@ -27,9 +27,7 @@ def apply_monkeypatch(monkeypatch):
|
|
|
27
27
|
)
|
|
28
28
|
monkeypatch.setattr("fastapi.routing.APIRoute", DeferringAPIRoute)
|
|
29
29
|
monkeypatch.setattr("fastapi.routing.APIRouter", DeferringAPIRouter)
|
|
30
|
-
|
|
31
|
-
# "fastapi.APIRouter", DeferringAPIRouter
|
|
32
|
-
# )
|
|
30
|
+
monkeypatch.setattr("fastapi.APIRouter", DeferringAPIRouter)
|
|
33
31
|
|
|
34
32
|
|
|
35
33
|
@pytest.mark.parametrize(["use_lib"], [(True,), (False,)])
|
|
@@ -42,7 +40,7 @@ def test_basic(use_lib: bool, benchmark, monkeypatch):
|
|
|
42
40
|
)
|
|
43
41
|
|
|
44
42
|
generated_code = benchmark(load_code)
|
|
45
|
-
|
|
43
|
+
assert generated_code.APIRouter is (DeferringAPIRouter if use_lib else APIRouter)
|
|
46
44
|
app = FastAPI()
|
|
47
45
|
router = generated_code.router
|
|
48
46
|
|
|
File without changes
|
|
File without changes
|
{fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/__init__.py
RENAMED
|
File without changes
|
{fastapi_deferred_init-0.3.0 → fastapi_deferred_init-0.3.1}/src/fastapi_deferred_init/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|