def__init__(
-self,
-body:Optional[AnyDict]=None,
-headers:Optional[AnyDict]=None,
-path:Optional[AnyDict]=None,
-)->None:
-"""Initialize a class instance.
-
- Args:
- body: The body of the request as a dictionary. Default is None.
- headers: The headers of the request as a dictionary. Default is None.
-
- Attributes:
- scope: A dictionary to store the scope of the request.
- _cookies: A dictionary to store the cookies of the request.
- _headers: A dictionary to store the headers of the request.
- _body: A dictionary to store the body of the request.
- _query_params: A dictionary to store the query parameters of the request.
-
- """
-self.scope={"path_params":pathor{}}
-self._cookies={}
-self._headers=headersor{}
-self._body=bodyor{}
-self._query_params={**self._body,**(pathor{})}
+171
+172
+173
+174
def__init__(
+self,
+*,
+body:Union[AnyDict,List[Any]],
+headers:AnyDict,
+path:AnyDict,
+)->None:
+"""Initialize a class instance.
+
+ Args:
+ body: The body of the request as a dictionary.
+ headers: The headers of the request as a dictionary.
+
+ Attributes:
+ scope: A dictionary to store the scope of the request.
+ _cookies: A dictionary to store the cookies of the request.
+ _headers: A dictionary to store the headers of the request.
+ _body: A dictionary to store the body of the request.
+ _query_params: A dictionary to store the query parameters of the request.
+
+ """
+self._headers=headers
+self._body=body
+self._query_params=path
+
+self.scope={"path_params":self._query_params}
+self._cookies={}
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
@classmethod
-defget_session(
-cls,
-dependant:Dependant,
-dependency_overrides_provider:Optional[Any]=None,
-)->Callable[[NativeMessage[Any]],Awaitable[SendableMessage]]:
-"""Creates a session for handling requests.
-
- Args:
- dependant: The dependant object representing the session.
- dependency_overrides_provider: Optional provider for dependency overrides.
-
- Returns:
- A callable that takes a native message and returns an awaitable sendable message.
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
@classmethod
+defget_session(
+cls,
+dependant:Dependant,
+dependency_overrides_provider:Optional[Any]=None,
+)->Callable[[NativeMessage[Any]],Awaitable[SendableMessage]]:
+"""Creates a session for handling requests.
+
+ Args:
+ dependant: The dependant object representing the session.
+ dependency_overrides_provider: Optional provider for dependency overrides.
- Raises:
- AssertionError: If the dependant call is not defined.
+ Returns:
+ A callable that takes a native message and returns an awaitable sendable message.
- Note:
- This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
+ Raises:
+ AssertionError: If the dependant call is not defined.
- """
-assertdependant.call# nosec B101
+ Note:
+ This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
-func=get_app(dependant,dependency_overrides_provider)
-
-dependencies_names=tuple(i.nameforiindependant.dependencies)
-
-first_arg=next(
-dropwhile(
-lambdai:iindependencies_names,
-inspect.signature(dependant.call).parameters,
-),
-None,
-)
-
-asyncdefapp(message:NativeMessage[Any])->SendableMessage:
-"""An asynchronous function that processes an incoming message and returns a sendable message.
+ """
+assertdependant.call# nosec B101
+
+func=get_app(dependant,dependency_overrides_provider)
+
+dependencies_names=tuple(i.nameforiindependant.dependencies)
+
+first_arg=next(
+dropwhile(
+lambdai:iindependencies_names,
+inspect.signature(dependant.call).parameters,
+),
+None,
+)
- Args:
- message : The incoming message to be processed
+asyncdefapp(message:NativeMessage[Any])->SendableMessage:
+"""An asynchronous function that processes an incoming message and returns a sendable message.
- Returns:
- The sendable message
+ Args:
+ message : The incoming message to be processed
- Raises:
- TypeError: If the body of the message is not a dictionary
- !!! note
-
- The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
- """
-body=message.decoded_body
-iffirst_argisnotNone:
-ifnotisinstance(body,dict)andnotisinstance(body,list):
-fastapi_body:Any={first_arg:body}
-else:
-fastapi_body=body
-
-session=cls(fastapi_body,message.headers,message.path)
-else:
-session=cls()
-returnawaitfunc(session)
-
-returnapp
+ Returns:
+ The sendable message
+
+ Raises:
+ TypeError: If the body of the message is not a dictionary
+ !!! note
+
+ The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
+ """
+body=message.decoded_body
+
+fastapi_body:Union[AnyDict,List[Any]]
+iffirst_argisnotNone:
+ifisinstance(body,dict):
+path=fastapi_body=bodyor{}
+elifisinstance(body,list):
+fastapi_body,path=body,{}
+else:
+path=fastapi_body={first_arg:body}
+
+session=cls(
+body=fastapi_body,
+headers=message.headers,
+path={**path,**message.path},
+)
+
+else:
+session=cls(
+body={},
+headers={},
+path={},
+)
+
+returnawaitfunc(session)
+
+returnapp
def__init__(
-self,
-body:Optional[AnyDict]=None,
-headers:Optional[AnyDict]=None,
-path:Optional[AnyDict]=None,
-)->None:
-"""Initialize a class instance.
-
- Args:
- body: The body of the request as a dictionary. Default is None.
- headers: The headers of the request as a dictionary. Default is None.
-
- Attributes:
- scope: A dictionary to store the scope of the request.
- _cookies: A dictionary to store the cookies of the request.
- _headers: A dictionary to store the headers of the request.
- _body: A dictionary to store the body of the request.
- _query_params: A dictionary to store the query parameters of the request.
-
- """
-self.scope={"path_params":pathor{}}
-self._cookies={}
-self._headers=headersor{}
-self._body=bodyor{}
-self._query_params={**self._body,**(pathor{})}
+171
+172
+173
+174
def__init__(
+self,
+*,
+body:Union[AnyDict,List[Any]],
+headers:AnyDict,
+path:AnyDict,
+)->None:
+"""Initialize a class instance.
+
+ Args:
+ body: The body of the request as a dictionary.
+ headers: The headers of the request as a dictionary.
+
+ Attributes:
+ scope: A dictionary to store the scope of the request.
+ _cookies: A dictionary to store the cookies of the request.
+ _headers: A dictionary to store the headers of the request.
+ _body: A dictionary to store the body of the request.
+ _query_params: A dictionary to store the query parameters of the request.
+
+ """
+self._headers=headers
+self._body=body
+self._query_params=path
+
+self.scope={"path_params":self._query_params}
+self._cookies={}
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
@classmethod
-defget_session(
-cls,
-dependant:Dependant,
-dependency_overrides_provider:Optional[Any]=None,
-)->Callable[[NativeMessage[Any]],Awaitable[SendableMessage]]:
-"""Creates a session for handling requests.
-
- Args:
- dependant: The dependant object representing the session.
- dependency_overrides_provider: Optional provider for dependency overrides.
-
- Returns:
- A callable that takes a native message and returns an awaitable sendable message.
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
@classmethod
+defget_session(
+cls,
+dependant:Dependant,
+dependency_overrides_provider:Optional[Any]=None,
+)->Callable[[NativeMessage[Any]],Awaitable[SendableMessage]]:
+"""Creates a session for handling requests.
+
+ Args:
+ dependant: The dependant object representing the session.
+ dependency_overrides_provider: Optional provider for dependency overrides.
- Raises:
- AssertionError: If the dependant call is not defined.
+ Returns:
+ A callable that takes a native message and returns an awaitable sendable message.
- Note:
- This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
+ Raises:
+ AssertionError: If the dependant call is not defined.
- """
-assertdependant.call# nosec B101
+ Note:
+ This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
-func=get_app(dependant,dependency_overrides_provider)
-
-dependencies_names=tuple(i.nameforiindependant.dependencies)
-
-first_arg=next(
-dropwhile(
-lambdai:iindependencies_names,
-inspect.signature(dependant.call).parameters,
-),
-None,
-)
-
-asyncdefapp(message:NativeMessage[Any])->SendableMessage:
-"""An asynchronous function that processes an incoming message and returns a sendable message.
+ """
+assertdependant.call# nosec B101
+
+func=get_app(dependant,dependency_overrides_provider)
+
+dependencies_names=tuple(i.nameforiindependant.dependencies)
+
+first_arg=next(
+dropwhile(
+lambdai:iindependencies_names,
+inspect.signature(dependant.call).parameters,
+),
+None,
+)
- Args:
- message : The incoming message to be processed
+asyncdefapp(message:NativeMessage[Any])->SendableMessage:
+"""An asynchronous function that processes an incoming message and returns a sendable message.
- Returns:
- The sendable message
+ Args:
+ message : The incoming message to be processed
- Raises:
- TypeError: If the body of the message is not a dictionary
- !!! note
-
- The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
- """
-body=message.decoded_body
-iffirst_argisnotNone:
-ifnotisinstance(body,dict)andnotisinstance(body,list):
-fastapi_body:Any={first_arg:body}
-else:
-fastapi_body=body
-
-session=cls(fastapi_body,message.headers,message.path)
-else:
-session=cls()
-returnawaitfunc(session)
-
-returnapp
+ Returns:
+ The sendable message
+
+ Raises:
+ TypeError: If the body of the message is not a dictionary
+ !!! note
+
+ The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
+ """
+body=message.decoded_body
+
+fastapi_body:Union[AnyDict,List[Any]]
+iffirst_argisnotNone:
+ifisinstance(body,dict):
+path=fastapi_body=bodyor{}
+elifisinstance(body,list):
+fastapi_body,path=body,{}
+else:
+path=fastapi_body={first_arg:body}
+
+session=cls(
+body=fastapi_body,
+headers=message.headers,
+path={**path,**message.path},
+)
+
+else:
+session=cls(
+body={},
+headers={},
+path={},
+)
+
+returnawaitfunc(session)
+
+returnapp
defget_app(
-dependant:Dependant,
-dependency_overrides_provider:Optional[Any]=None,
-)->Callable[[StreamMessage],Coroutine[Any,Any,SendableMessage]]:
-"""Creates a FastAPI application.
-
- Args:
- dependant: The dependant object that defines the endpoint function and its dependencies.
- dependency_overrides_provider: Optional provider for dependency overrides.
-
- Returns:
- The FastAPI application as a callable that takes a StreamMessage object as input and returns a SendableMessage coroutine.
-
- Raises:
- AssertionError: If the code reaches an unreachable state.
-
- """
-
-asyncdefapp(request:StreamMessage)->SendableMessage:
-"""Handle an HTTP request and return a response.
-
- Args:
- request: The incoming HTTP request.
-
- Returns:
- The response to be sent back to the client.
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
defget_app(
+dependant:Dependant,
+dependency_overrides_provider:Optional[Any]=None,
+)->Callable[[StreamMessage],Coroutine[Any,Any,SendableMessage]]:
+"""Creates a FastAPI application.
+
+ Args:
+ dependant: The dependant object that defines the endpoint function and its dependencies.
+ dependency_overrides_provider: Optional provider for dependency overrides.
- Raises:
- AssertionError: If the code reaches an unreachable point.
+ Returns:
+ The FastAPI application as a callable that takes a StreamMessage object as input and returns a SendableMessage coroutine.
- """
-asyncwithAsyncExitStack()asstack:
-request.scope["fastapi_astack"]=stack
-
-solved_result=awaitsolve_dependencies(
-request=request,
-body=request._body,
-dependant=dependant,
-dependency_overrides_provider=dependency_overrides_provider,
-)
+ Raises:
+ AssertionError: If the code reaches an unreachable state.
+
+ """
+
+asyncdefapp(request:StreamMessage)->SendableMessage:
+"""Handle an HTTP request and return a response.
+
+ Args:
+ request: The incoming HTTP request.
-values,errors,_,_2,_3=solved_result
-iferrors:
-raise_fastapi_validation_error(errors,request._body)
-
-returncast(
-SendableMessage,
-awaitrun_endpoint_function(
-dependant=dependant,
-values=values,
-is_coroutine=asyncio.iscoroutinefunction(dependant.call),
-),
-)
-
-raiseAssertionError("unreachable")
-
-returnapp
+ Returns:
+ The response to be sent back to the client.
+
+ Raises:
+ AssertionError: If the code reaches an unreachable point.
+
+ """
+asyncwithAsyncExitStack()asstack:
+request.scope["fastapi_astack"]=stack
+
+solved_result=awaitsolve_dependencies(
+request=request,
+body=request._body,
+dependant=dependant,
+dependency_overrides_provider=dependency_overrides_provider,
+)
+
+values,errors,_,_2,_3=solved_result
+iferrors:
+raise_fastapi_validation_error(errors,request._body)
+
+returncast(
+SendableMessage,
+awaitrun_endpoint_function(
+dependant=dependant,
+values=values,
+is_coroutine=asyncio.iscoroutinefunction(dependant.call),
+),
+)
+
+raiseAssertionError("unreachable")
+
+returnapp