faststream_fastapi 1.2.0__tar.gz → 1.3.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.
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/PKG-INFO +1 -1
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/pyproject.toml +1 -1
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/get_dependant.py +30 -3
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/faststream_api.py +2 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/LICENSE +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/README.md +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/__about__.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/__init__.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/__init__.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/asyncapi_router.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/background_middleware.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/config.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fastapi_compat.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/__init__.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/_compat.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/application.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/broker.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/constants.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/context.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/di.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/fs_re_exports/logger.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/logger.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/replace_context.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/wrap_callable_to_fastapi_compatible.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/asyncapi_config.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/context.py +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/py.typed +0 -0
- {faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/stream_message.py +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
from collections.abc import Callable, Iterable
|
|
3
|
+
from dataclasses import fields
|
|
3
4
|
from typing import Annotated, Any, Final, cast, get_args, get_origin
|
|
4
5
|
|
|
6
|
+
from fast_depends.library.serializer import OptionItem
|
|
5
7
|
from fast_depends.utils import get_typed_annotation
|
|
6
8
|
from fastapi.dependencies.models import Dependant
|
|
7
9
|
from fastapi.dependencies.utils import (
|
|
@@ -10,15 +12,30 @@ from fastapi.dependencies.utils import (
|
|
|
10
12
|
get_typed_signature,
|
|
11
13
|
)
|
|
12
14
|
from fastapi.params import Depends
|
|
13
|
-
from pydantic import Field
|
|
15
|
+
from pydantic import Field, create_model
|
|
14
16
|
|
|
15
17
|
from faststream_fastapi._internal.fs_re_exports._compat import PYDANTIC_V2, PydanticUndefined
|
|
16
18
|
|
|
17
19
|
|
|
20
|
+
class _FastStreamDependant(Dependant):
|
|
21
|
+
"""FastAPI dependant extended with fields required by FastStream."""
|
|
22
|
+
|
|
23
|
+
model: type[Any]
|
|
24
|
+
custom_fields: dict[str, Any]
|
|
25
|
+
flat_params: list[OptionItem]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _extend_fastapi_dependant(dependant: Dependant) -> _FastStreamDependant:
|
|
29
|
+
field_values = {
|
|
30
|
+
field.name: getattr(dependant, field.name) for field in fields(dependant) if field.init
|
|
31
|
+
}
|
|
32
|
+
return _FastStreamDependant(**field_values)
|
|
33
|
+
|
|
34
|
+
|
|
18
35
|
def get_fastapi_dependant(
|
|
19
36
|
orig_call: Callable[..., Any],
|
|
20
37
|
dependencies: Iterable[Depends],
|
|
21
|
-
) ->
|
|
38
|
+
) -> _FastStreamDependant:
|
|
22
39
|
dependent = get_fastapi_native_dependant(orig_call=orig_call, dependencies=dependencies)
|
|
23
40
|
return _patch_fastapi_dependent(dependent)
|
|
24
41
|
|
|
@@ -41,7 +58,8 @@ def get_fastapi_native_dependant(
|
|
|
41
58
|
return dependent
|
|
42
59
|
|
|
43
60
|
|
|
44
|
-
def _patch_fastapi_dependent(dependant: Dependant) ->
|
|
61
|
+
def _patch_fastapi_dependent(dependant: Dependant) -> _FastStreamDependant:
|
|
62
|
+
dependant = _extend_fastapi_dependant(dependant)
|
|
45
63
|
params = dependant.query_params + dependant.body_params
|
|
46
64
|
|
|
47
65
|
for d in dependant.dependencies:
|
|
@@ -117,6 +135,15 @@ def _patch_fastapi_dependent(dependant: Dependant) -> Dependant:
|
|
|
117
135
|
f,
|
|
118
136
|
)
|
|
119
137
|
|
|
138
|
+
dependant.model = create_model(
|
|
139
|
+
getattr(call, "__name__", type(call).__name__),
|
|
140
|
+
)
|
|
141
|
+
dependant.custom_fields = {}
|
|
142
|
+
dependant.flat_params = [
|
|
143
|
+
OptionItem(field_name=name, field_type=type_, default_value=default)
|
|
144
|
+
for name, (type_, default) in params_unique.items()
|
|
145
|
+
]
|
|
146
|
+
|
|
120
147
|
return dependant
|
|
121
148
|
|
|
122
149
|
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/faststream_api.py
RENAMED
|
@@ -107,6 +107,8 @@ class FastStreamAPI:
|
|
|
107
107
|
return self._startable_application.context
|
|
108
108
|
|
|
109
109
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
110
|
+
scope["app"] = self._application
|
|
111
|
+
|
|
110
112
|
if scope["type"] == "lifespan":
|
|
111
113
|
await self.lifespan(scope, receive, send)
|
|
112
114
|
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/_internal/logger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/asyncapi_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faststream_fastapi-1.2.0 → faststream_fastapi-1.3.0}/src/faststream_fastapi/stream_message.py
RENAMED
|
File without changes
|