diff --git a/litestar/_openapi/path_item.py b/litestar/_openapi/path_item.py index 2abf4c895f..2209567a5d 100644 --- a/litestar/_openapi/path_item.py +++ b/litestar/_openapi/path_item.py @@ -36,7 +36,7 @@ def get_description_for_handler(route_handler: HTTPRouteHandler, use_handler_doc """ handler_description = route_handler.description if handler_description is None and use_handler_docstrings: - fn = unwrap_partial(route_handler.fn.value) + fn = unwrap_partial(route_handler.fn) return cleandoc(fn.__doc__) if fn.__doc__ else None return handler_description diff --git a/litestar/app.py b/litestar/app.py index 962e928df6..f34a1679c8 100644 --- a/litestar/app.py +++ b/litestar/app.py @@ -763,7 +763,7 @@ def url_for_static_asset(self, name: str, file_path: str) -> str: if handler_index is None: raise NoRouteMatchFoundException(f"Static handler {name} can not be found") - handler_fn = cast("AnyCallable", handler_index["handler"].fn.value) + handler_fn = cast("AnyCallable", handler_index["handler"].fn) if not isinstance(handler_fn, StaticFiles): raise NoRouteMatchFoundException(f"Handler with name {name} is not a static files handler") diff --git a/litestar/cli/commands/core.py b/litestar/cli/commands/core.py index 070336cd7f..24b0d8880c 100644 --- a/litestar/cli/commands/core.py +++ b/litestar/cli/commands/core.py @@ -257,7 +257,7 @@ def routes_command(app: Litestar) -> None: # pragma: no cover f"[blue]{handler.name or handler.handler_name}[/blue]", ] - if inspect.iscoroutinefunction(unwrap_partial(handler.fn.value)): + if inspect.iscoroutinefunction(unwrap_partial(handler.fn)): handler_info.append("[magenta]async[/magenta]") else: handler_info.append("[yellow]sync[/yellow]") diff --git a/litestar/controller.py b/litestar/controller.py index 0815629289..cd2cc84fad 100644 --- a/litestar/controller.py +++ b/litestar/controller.py @@ -1,8 +1,8 @@ from __future__ import annotations +import types from collections import defaultdict from copy import deepcopy -from functools import partial from operator import attrgetter from typing import TYPE_CHECKING, Any, Mapping, Sequence, cast @@ -209,7 +209,9 @@ def get_route_handlers(self) -> list[BaseRouteHandler]: self_handlers.sort(key=attrgetter("handler_id")) for self_handler in self_handlers: route_handler = deepcopy(self_handler) - route_handler.fn.value = partial(route_handler.fn.value, self) + # at the point we get a reference to the handler function, it's unbound, so + # we replace it with a regular bound method here + route_handler._fn = types.MethodType(route_handler._fn, self) route_handler.owner = self route_handlers.append(route_handler) diff --git a/litestar/di.py b/litestar/di.py index 7f5f27f9f9..9f4292d940 100644 --- a/litestar/di.py +++ b/litestar/di.py @@ -5,7 +5,7 @@ from litestar.exceptions import ImproperlyConfiguredException from litestar.types import Empty -from litestar.utils import Ref, ensure_async_callable +from litestar.utils import ensure_async_callable from litestar.utils.predicates import is_async_callable, is_sync_or_async_generator from litestar.utils.warnings import ( warn_implicit_sync_to_thread, @@ -35,7 +35,7 @@ class Provide: ) signature_model: type[SignatureModel] - dependency: Ref[AnyCallable] + dependency: AnyCallable def __init__( self, @@ -64,10 +64,10 @@ def __init__( warn_implicit_sync_to_thread(dependency, stacklevel=3) if sync_to_thread and has_sync_callable: - self.dependency = Ref["AnyCallable"](ensure_async_callable(dependency)) # pyright: ignore + self.dependency = ensure_async_callable(dependency) # pyright: ignore self.has_sync_callable = False else: - self.dependency = Ref["AnyCallable"](dependency) # pyright: ignore + self.dependency = dependency # pyright: ignore self.has_sync_callable = has_sync_callable self.sync_to_thread = bool(sync_to_thread) @@ -81,9 +81,9 @@ async def __call__(self, **kwargs: Any) -> Any: return self.value if self.has_sync_callable: - value = self.dependency.value(**kwargs) + value = self.dependency(**kwargs) else: - value = await self.dependency.value(**kwargs) + value = await self.dependency(**kwargs) if self.use_cache: self.value = value diff --git a/litestar/handlers/asgi_handlers.py b/litestar/handlers/asgi_handlers.py index daee7e5aa1..91f35172d3 100644 --- a/litestar/handlers/asgi_handlers.py +++ b/litestar/handlers/asgi_handlers.py @@ -83,7 +83,7 @@ def _validate_handler_function(self) -> None: raise ImproperlyConfiguredException( "ASGI handler functions should define 'scope', 'send' and 'receive' arguments" ) - if not is_async_callable(self.fn.value): + if not is_async_callable(self.fn): raise ImproperlyConfiguredException("Functions decorated with 'asgi' must be async functions") diff --git a/litestar/handlers/base.py b/litestar/handlers/base.py index 59894dd803..c7078bb1ed 100644 --- a/litestar/handlers/base.py +++ b/litestar/handlers/base.py @@ -14,13 +14,12 @@ Empty, ExceptionHandlersMap, Guard, - MaybePartial, Middleware, TypeDecodersSequence, TypeEncodersMap, ) from litestar.typing import FieldDefinition -from litestar.utils import Ref, ensure_async_callable, get_name, normalize_path +from litestar.utils import ensure_async_callable, get_name, normalize_path from litestar.utils.helpers import unwrap_partial from litestar.utils.signature import ParsedSignature, add_types_to_signature_namespace @@ -155,7 +154,7 @@ def __init__( def __call__(self, fn: AsyncAnyCallable) -> Self: """Replace a function with itself.""" - self._fn = Ref["MaybePartial[AsyncAnyCallable]"](fn) + self._fn = fn return self @property @@ -194,7 +193,7 @@ def signature_model(self) -> type[SignatureModel]: if self._signature_model is Empty: self._signature_model = SignatureModel.create( dependency_name_set=self.dependency_name_set, - fn=cast("AnyCallable", self.fn.value), + fn=cast("AnyCallable", self.fn), parsed_signature=self.parsed_fn_signature, data_dto=self.resolve_data_dto(), type_decoders=self.resolve_type_decoders(), @@ -202,7 +201,7 @@ def signature_model(self) -> type[SignatureModel]: return cast("type[SignatureModel]", self._signature_model) @property - def fn(self) -> Ref[MaybePartial[AsyncAnyCallable]]: + def fn(self) -> AsyncAnyCallable: """Get the handler function. Raises: @@ -226,7 +225,7 @@ def parsed_fn_signature(self) -> ParsedSignature: """ if self._parsed_fn_signature is Empty: self._parsed_fn_signature = ParsedSignature.from_fn( - unwrap_partial(self.fn.value), self.resolve_signature_namespace() + unwrap_partial(self.fn), self.resolve_signature_namespace() ) return cast("ParsedSignature", self._parsed_fn_signature) @@ -253,7 +252,7 @@ def handler_name(self) -> str: Returns: Name of the handler function """ - return get_name(unwrap_partial(self.fn.value)) + return get_name(unwrap_partial(self.fn)) @property def dependency_name_set(self) -> set[str]: @@ -358,9 +357,9 @@ def resolve_dependencies(self) -> dict[str, Provide]: if not getattr(provider, "signature_model", None): provider.signature_model = SignatureModel.create( dependency_name_set=self.dependency_name_set, - fn=provider.dependency.value, + fn=provider.dependency, parsed_signature=ParsedSignature.from_fn( - unwrap_partial(provider.dependency.value), self.resolve_signature_namespace() + unwrap_partial(provider.dependency), self.resolve_signature_namespace() ), data_dto=self.resolve_data_dto(), type_decoders=self.resolve_type_decoders(), @@ -537,7 +536,7 @@ def __str__(self) -> str: A string """ target: type[AsyncAnyCallable] | AsyncAnyCallable # pyright: ignore - target = unwrap_partial(self.fn.value) + target = unwrap_partial(self.fn) if not hasattr(target, "__qualname__"): target = type(target) return f"{target.__module__}.{target.__qualname__}" diff --git a/litestar/handlers/http_handlers/base.py b/litestar/handlers/http_handlers/base.py index 9a6a32363d..b7f8b1c344 100644 --- a/litestar/handlers/http_handlers/base.py +++ b/litestar/handlers/http_handlers/base.py @@ -490,10 +490,10 @@ def on_registration(self, app: Litestar) -> None: super().on_registration(app) self.resolve_after_response() self.resolve_include_in_schema() - self.has_sync_callable = not is_async_callable(self.fn.value) + self.has_sync_callable = not is_async_callable(self.fn) if self.has_sync_callable and self.sync_to_thread: - self.fn.value = ensure_async_callable(self.fn.value) + self._fn = ensure_async_callable(self.fn) self.has_sync_callable = False def _validate_handler_function(self) -> None: diff --git a/litestar/handlers/websocket_handlers/listener.py b/litestar/handlers/websocket_handlers/listener.py index 85ff440fc1..6363f4335f 100644 --- a/litestar/handlers/websocket_handlers/listener.py +++ b/litestar/handlers/websocket_handlers/listener.py @@ -255,7 +255,7 @@ def signature_model(self) -> type[SignatureModel]: if self._signature_model is Empty: self._signature_model = SignatureModel.create( dependency_name_set=self.dependency_name_set, - fn=cast("AnyCallable", self.fn.value), + fn=cast("AnyCallable", self.fn), parsed_signature=self.parsed_fn_signature, type_decoders=self.resolve_type_decoders(), ) diff --git a/litestar/handlers/websocket_handlers/route_handler.py b/litestar/handlers/websocket_handlers/route_handler.py index c6dafa995a..47a87fe8fa 100644 --- a/litestar/handlers/websocket_handlers/route_handler.py +++ b/litestar/handlers/websocket_handlers/route_handler.py @@ -74,7 +74,7 @@ def _validate_handler_function(self) -> None: if param in self.parsed_fn_signature.parameters: raise ImproperlyConfiguredException(f"The {param} kwarg is not supported with websocket handlers") - if not is_async_callable(self.fn.value): + if not is_async_callable(self.fn): raise ImproperlyConfiguredException("Functions decorated with 'websocket' must be async functions") diff --git a/litestar/middleware/compression.py b/litestar/middleware/compression.py index e6443f05b2..760b8a174f 100644 --- a/litestar/middleware/compression.py +++ b/litestar/middleware/compression.py @@ -2,14 +2,14 @@ from gzip import GzipFile from io import BytesIO -from typing import TYPE_CHECKING, Any, Literal, Optional +from typing import TYPE_CHECKING, Any, Literal from litestar.constants import SCOPE_STATE_IS_CACHED, SCOPE_STATE_RESPONSE_COMPRESSED from litestar.datastructures import Headers, MutableScopeHeaders from litestar.enums import CompressionEncoding, ScopeType from litestar.exceptions import MissingDependencyException from litestar.middleware.base import AbstractMiddleware -from litestar.utils import Ref, get_litestar_scope_state, set_litestar_scope_state +from litestar.utils import get_litestar_scope_state, set_litestar_scope_state __all__ = ("CompressionFacade", "CompressionMiddleware") @@ -173,8 +173,8 @@ def create_compression_send_wrapper( bytes_buffer = BytesIO() facade = CompressionFacade(buffer=bytes_buffer, compression_encoding=compression_encoding, config=self.config) - initial_message = Ref[Optional["HTTPResponseStartEvent"]](None) - started = Ref[bool](False) + initial_message: HTTPResponseStartEvent | None = None + started = False _own_encoding = compression_encoding.encode("latin-1") @@ -184,24 +184,26 @@ async def send_wrapper(message: Message) -> None: Args: message (Message): An ASGI Message. """ + nonlocal started + nonlocal initial_message if message["type"] == "http.response.start": - initial_message.value = message + initial_message = message return - if initial_message.value and get_litestar_scope_state(scope, SCOPE_STATE_IS_CACHED): - await send(initial_message.value) + if initial_message and get_litestar_scope_state(scope, SCOPE_STATE_IS_CACHED): + await send(initial_message) await send(message) return - if initial_message.value and message["type"] == "http.response.body": + if initial_message and message["type"] == "http.response.body": body = message["body"] more_body = message.get("more_body") - if not started.value: - started.value = True + if not started: + started = True if more_body: - headers = MutableScopeHeaders(initial_message.value) + headers = MutableScopeHeaders(initial_message) headers["Content-Encoding"] = compression_encoding headers.extend_header_value("vary", "Accept-Encoding") del headers["Content-Length"] @@ -212,7 +214,7 @@ async def send_wrapper(message: Message) -> None: message["body"] = bytes_buffer.getvalue() bytes_buffer.seek(0) bytes_buffer.truncate() - await send(initial_message.value) + await send(initial_message) await send(message) elif len(body) >= self.config.minimum_size: @@ -220,18 +222,18 @@ async def send_wrapper(message: Message) -> None: facade.close() body = bytes_buffer.getvalue() - headers = MutableScopeHeaders(initial_message.value) + headers = MutableScopeHeaders(initial_message) headers["Content-Encoding"] = compression_encoding headers["Content-Length"] = str(len(body)) headers.extend_header_value("vary", "Accept-Encoding") message["body"] = body set_litestar_scope_state(scope, SCOPE_STATE_RESPONSE_COMPRESSED, True) - await send(initial_message.value) + await send(initial_message) await send(message) else: - await send(initial_message.value) + await send(initial_message) await send(message) else: diff --git a/litestar/routes/asgi.py b/litestar/routes/asgi.py index 6802a913ef..a8564d0e61 100644 --- a/litestar/routes/asgi.py +++ b/litestar/routes/asgi.py @@ -51,4 +51,4 @@ async def handle(self, scope: Scope, receive: Receive, send: Send) -> None: connection = ASGIConnection["ASGIRouteHandler", Any, Any, Any](scope=scope, receive=receive) await self.route_handler.authorize_connection(connection=connection) - await self.route_handler.fn.value(scope=scope, receive=receive, send=send) + await self.route_handler.fn(scope=scope, receive=receive, send=send) diff --git a/litestar/routes/http.py b/litestar/routes/http.py index 2582439f8c..d0286ddad7 100644 --- a/litestar/routes/http.py +++ b/litestar/routes/http.py @@ -191,14 +191,14 @@ async def _get_response_data( if cleanup_group: async with cleanup_group: data = ( - route_handler.fn.value(**parsed_kwargs) + route_handler.fn(**parsed_kwargs) if route_handler.has_sync_callable - else await route_handler.fn.value(**parsed_kwargs) + else await route_handler.fn(**parsed_kwargs) ) elif route_handler.has_sync_callable: - data = route_handler.fn.value(**parsed_kwargs) + data = route_handler.fn(**parsed_kwargs) else: - data = await route_handler.fn.value(**parsed_kwargs) + data = await route_handler.fn(**parsed_kwargs) return data, cleanup_group diff --git a/litestar/routes/websocket.py b/litestar/routes/websocket.py index b3ffe27b94..9b309fe107 100644 --- a/litestar/routes/websocket.py +++ b/litestar/routes/websocket.py @@ -77,7 +77,7 @@ async def handle(self, scope: WebSocketScope, receive: Receive, send: Send) -> N if cleanup_group: async with cleanup_group: - await self.route_handler.fn.value(**parsed_kwargs) + await self.route_handler.fn(**parsed_kwargs) await cleanup_group.cleanup() else: - await self.route_handler.fn.value(**parsed_kwargs) + await self.route_handler.fn(**parsed_kwargs) diff --git a/litestar/utils/__init__.py b/litestar/utils/__init__.py index 795845ca43..6eca50ea57 100644 --- a/litestar/utils/__init__.py +++ b/litestar/utils/__init__.py @@ -1,6 +1,6 @@ from litestar.utils.deprecation import deprecated, warn_deprecation -from .helpers import Ref, get_enum_string_value, get_name, unique_name_for_scope, url_quote +from .helpers import get_enum_string_value, get_name, unique_name_for_scope, url_quote from .path import join_paths, normalize_path from .predicates import ( is_annotated_type, @@ -33,7 +33,6 @@ __all__ = ( "ensure_async_callable", "AsyncIteratorWrapper", - "Ref", "delete_litestar_scope_state", "deprecated", "find_index", diff --git a/litestar/utils/helpers.py b/litestar/utils/helpers.py index cc87238f80..b9d7218e58 100644 --- a/litestar/utils/helpers.py +++ b/litestar/utils/helpers.py @@ -1,9 +1,8 @@ from __future__ import annotations -from dataclasses import dataclass from enum import Enum from functools import partial -from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast +from typing import TYPE_CHECKING, Any, TypeVar, cast from urllib.parse import quote from litestar.utils.typing import get_origin_or_inner_type @@ -14,7 +13,6 @@ from litestar.types import MaybePartial __all__ = ( - "Ref", "get_enum_string_value", "get_name", "unwrap_partial", @@ -60,16 +58,6 @@ def get_enum_string_value(value: Enum | str) -> str: return value.value if isinstance(value, Enum) else value # type:ignore -@dataclass -class Ref(Generic[T]): - """A helper class that encapsulates a value.""" - - __slots__ = ("value",) - - value: T - """The value wrapped by the ref.""" - - def unwrap_partial(value: MaybePartial[T]) -> T: """Unwraps a partial, returning the underlying callable. diff --git a/tests/unit/test_kwargs/test_query_params.py b/tests/unit/test_kwargs/test_query_params.py index c19ec908eb..a8541c844b 100644 --- a/tests/unit/test_kwargs/test_query_params.py +++ b/tests/unit/test_kwargs/test_query_params.py @@ -145,7 +145,7 @@ def test_method_without_default(param: Any) -> None: test_method = test_method_without_default if default is ... else test_method_with_default # Set the type annotation of 'param' in a way mypy can deal with - test_method.fn.value.__annotations__["param"] = expected_type + test_method.fn.__annotations__["param"] = expected_type with create_test_client(test_method) as client: params = urlencode({"param": provided_value}, doseq=True) diff --git a/tests/unit/test_openapi/test_parameters.py b/tests/unit/test_openapi/test_parameters.py index 03cbf0021a..8d85091694 100644 --- a/tests/unit/test_openapi/test_parameters.py +++ b/tests/unit/test_openapi/test_parameters.py @@ -28,7 +28,7 @@ def _create_parameters(app: Litestar, path: str) -> List["OpenAPIParameter"]: route = app.routes[index] route_handler = route.route_handler_map["GET"][0] # type: ignore - handler = route_handler.fn.value + handler = route_handler.fn assert callable(handler) handler_fields = SignatureModel.create( diff --git a/tests/unit/test_response/test_response_to_asgi_response.py b/tests/unit/test_response/test_response_to_asgi_response.py index 15ac3bdfa2..966e473f20 100644 --- a/tests/unit/test_response/test_response_to_asgi_response.py +++ b/tests/unit/test_response/test_response_to_asgi_response.py @@ -81,14 +81,14 @@ async def handler(data: DataclassPerson) -> DataclassPerson: person_instance = DataclassPersonFactory.build() handler._signature_model = SignatureModel.create( dependency_name_set=set(), - fn=handler.fn.value, + fn=handler.fn, data_dto=None, - parsed_signature=ParsedSignature.from_fn(handler.fn.value, {}), + parsed_signature=ParsedSignature.from_fn(handler.fn, {}), type_decoders=[], ) response = await handler.to_response( - data=handler.fn.value(data=person_instance), + data=handler.fn(data=person_instance), app=Litestar(route_handlers=[handler]), request=RequestFactory().get(route_handler=handler), ) @@ -104,7 +104,7 @@ def handler() -> Response: http_route: HTTPRoute = client.app.routes[0] route_handler = http_route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) assert isinstance(response, ASGIResponse) @@ -129,7 +129,7 @@ def handler() -> StarletteResponse: http_route: HTTPRoute = client.app.routes[0] route_handler = http_route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) assert isinstance(response, StarletteResponse) assert response is expected_response # type: ignore[unreachable] @@ -156,7 +156,7 @@ def handler() -> Redirect: route: HTTPRoute = client.app.routes[0] route_handler = route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) encoded_headers = response.encode_headers() # type: ignore[attr-defined] @@ -210,7 +210,7 @@ def handler() -> File: route: HTTPRoute = client.app.routes[0] route_handler = route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) assert isinstance(response, ASGIFileResponse) assert response.file_info @@ -267,12 +267,10 @@ def handler() -> Stream: route_handler = route.route_handlers[0] if should_raise: with pytest.raises(TypeError): - await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() - ) + await route_handler.to_response(data=route_handler.fn(), app=client.app, request=RequestFactory().get()) else: response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) assert isinstance(response, ASGIStreamingResponse) encoded_headers = response.encode_headers() @@ -318,7 +316,7 @@ def handler() -> Template: route: HTTPRoute = client.app.routes[0] route_handler = route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory(app=app).get() + data=route_handler.fn(), app=client.app, request=RequestFactory(app=app).get() ) assert isinstance(response, ASGIResponse) encoded_headers = response.encode_headers() @@ -369,7 +367,7 @@ def handler() -> ServerSentEvent: route: HTTPRoute = client.app.routes[0] route_handler = route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) encoded_headers = response.encode_headers() # type: ignore[attr-defined] @@ -414,7 +412,7 @@ def handler() -> ServerSentEvent: route: HTTPRoute = client.app.routes[0] route_handler = route.route_handlers[0] response = await route_handler.to_response( - data=route_handler.fn.value(), app=client.app, request=RequestFactory().get() + data=route_handler.fn(), app=client.app, request=RequestFactory().get() ) assert isinstance(response, ASGIStreamingResponse) async for value in response.iterator: diff --git a/tests/unit/test_signature/test_parsing.py b/tests/unit/test_signature/test_parsing.py index 24dbb8b02e..25d47e58a7 100644 --- a/tests/unit/test_signature/test_parsing.py +++ b/tests/unit/test_signature/test_parsing.py @@ -21,9 +21,9 @@ def my_fn(a: int, b: str, c: Optional[bytes], d: bytes = b"123", e: Optional[dic model = SignatureModel.create( dependency_name_set=set(), - fn=my_fn.fn.value, + fn=my_fn.fn, data_dto=None, - parsed_signature=ParsedSignature.from_fn(my_fn.fn.value, {}), + parsed_signature=ParsedSignature.from_fn(my_fn.fn, {}), type_decoders=[], ) fields = model._fields @@ -48,9 +48,9 @@ async def health_check() -> None: signature_model_type = SignatureModel.create( dependency_name_set=set(), - fn=health_check.fn.value, + fn=health_check.fn, data_dto=None, - parsed_signature=ParsedSignature.from_fn(health_check.fn.value, {}), + parsed_signature=ParsedSignature.from_fn(health_check.fn, {}), type_decoders=[], ) assert signature_model_type().to_dict() == {} diff --git a/tests/unit/test_signature/test_validation.py b/tests/unit/test_signature/test_validation.py index 19fead9c6c..c20b317dbf 100644 --- a/tests/unit/test_signature/test_validation.py +++ b/tests/unit/test_signature/test_validation.py @@ -38,9 +38,9 @@ def my_fn(typed: int, untyped) -> None: # type: ignore with pytest.raises(ImproperlyConfiguredException): SignatureModel.create( dependency_name_set=set(), - fn=my_fn.fn.value, + fn=my_fn.fn, data_dto=None, - parsed_signature=ParsedSignature.from_fn(my_fn.fn.value, {}), + parsed_signature=ParsedSignature.from_fn(my_fn.fn, {}), type_decoders=[], ) @@ -124,7 +124,7 @@ def handler(data: Parent) -> None: dependency_name_set=set(), fn=handler, data_dto=None, - parsed_signature=ParsedSignature.from_fn(handler.fn.value, {}), + parsed_signature=ParsedSignature.from_fn(handler.fn, {}), type_decoders=[], ) diff --git a/tests/unit/test_utils/test_predicates.py b/tests/unit/test_utils/test_predicates.py index 9f1fdf588e..6e45da3c5c 100644 --- a/tests/unit/test_utils/test_predicates.py +++ b/tests/unit/test_utils/test_predicates.py @@ -65,8 +65,8 @@ class Sub(C): "args, expected", ( ((Sub, C), True), - ((Signature.from_callable(cast("Any", naive_handler.fn.value)).return_annotation, C), False), - ((Signature.from_callable(cast("Any", response_handler.fn.value)).return_annotation, Response), True), + ((Signature.from_callable(cast("Any", naive_handler.fn)).return_annotation, C), False), + ((Signature.from_callable(cast("Any", response_handler.fn)).return_annotation, Response), True), ((Dict[str, Any], C), False), ((C(), C), False), ),