starlite.types#
Callable types#
- starlite.types.AfterExceptionHookHandler#
alias of
Callable
[[Exception
,Union
[HTTPScope
,WebSocketScope
],Any
],Union
[None
,Awaitable
[None
]]]
- starlite.types.AfterRequestHookHandler#
alias of
Union
[Callable
[[Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]]],Union
[Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]],Awaitable
[Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]]]]],Callable
[[Any
],Union
[Any
,Awaitable
[Any
]]]]
- starlite.types.BeforeMessageSendHookHandler#
alias of
Union
[Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
],Any
,Union
[HTTPScope
,WebSocketScope
]],Union
[None
,Awaitable
[None
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
],Any
],Union
[None
,Awaitable
[None
]]]]
ASGI Types#
- starlite.types.Method#
alias of
Literal
[‘GET’, ‘POST’, ‘DELETE’, ‘PATCH’, ‘PUT’, ‘HEAD’, ‘TRACE’, ‘OPTIONS’]
ASGI Application#
- starlite.types.ASGIApp#
alias of
Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]]
ASGI Application Parameters#
- starlite.types.Receive#
alias of
Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]]
- starlite.types.Send#
alias of
Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]
ASGI Scopes#
- starlite.types.ASGIVersion = <class 'starlite.types.asgi_types.ASGIVersion'>#
ASGI spec version.
- starlite.types.BaseScope = <class 'starlite.types.asgi_types.BaseScope'>#
Base ASGI-scope.
- starlite.types.WebSocketScope = <class 'starlite.types.asgi_types.WebSocketScope'>#
WebSocket-ASGI-scope.
- starlite.types.HTTPScope = <class 'starlite.types.asgi_types.HTTPScope'>#
HTTP-ASGI-scope.
- starlite.types.LifeSpanScope = <class 'starlite.types.asgi_types.LifeSpanScope'>#
Lifespan-ASGI-scope.
ASGI Events#
- class starlite.types.HTTPRequestEvent#
Bases:
TypedDict
ASGI http.request event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.HTTPResponseStartEvent#
Bases:
HeaderScope
ASGI http.response.start event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.HTTPResponseBodyEvent#
Bases:
TypedDict
ASGI http.response.body event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.HTTPServerPushEvent#
Bases:
HeaderScope
ASGI http.response.push event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.HTTPDisconnectEvent#
Bases:
TypedDict
ASGI http.disconnect event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketConnectEvent#
Bases:
TypedDict
ASGI websocket.connect event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketAcceptEvent#
Bases:
HeaderScope
ASGI websocket.accept event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketReceiveEvent#
Bases:
TypedDict
ASGI websocket.receive event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketSendEvent#
Bases:
TypedDict
ASGI websocket.send event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketResponseStartEvent#
Bases:
HeaderScope
ASGI websocket.http.response.start event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketResponseBodyEvent#
Bases:
TypedDict
ASGI websocket.http.response.body event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketDisconnectEvent#
Bases:
TypedDict
ASGI websocket.disconnect event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.WebSocketCloseEvent#
Bases:
TypedDict
ASGI websocket.close event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.LifeSpanStartupEvent#
Bases:
TypedDict
ASGI lifespan.startup event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.LifeSpanShutdownEvent#
Bases:
TypedDict
ASGI lifespan.shutdown event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.LifeSpanStartupCompleteEvent#
Bases:
TypedDict
ASGI lifespan.startup.complete event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
- class starlite.types.LifeSpanStartupFailedEvent#
Bases:
TypedDict
ASGI lifespan.startup.failed event.
- __init__(*args, **kwargs)#
- __new__(**kwargs)#
Event Groupings#
- starlite.types.HTTPReceiveMessage#
alias of
Union
[HTTPRequestEvent
,HTTPDisconnectEvent
]
- starlite.types.WebSocketReceiveMessage#
alias of
Union
[WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]
- starlite.types.LifeSpanReceiveMessage#
alias of
Union
[LifeSpanStartupEvent
,LifeSpanShutdownEvent
]
- starlite.types.HTTPSendMessage#
alias of
Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
]
- starlite.types.WebSocketSendMessage#
alias of
Union
[WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]
- starlite.types.LifeSpanSendMessage#
alias of
Union
[LifeSpanStartupCompleteEvent
,LifeSpanStartupFailedEvent
,LifeSpanShutdownCompleteEvent
,LifeSpanShutdownFailedEvent
]
- starlite.types.LifeSpanReceive#
alias of
Callable
[[…],Awaitable
[Union
[LifeSpanStartupEvent
,LifeSpanShutdownEvent
]]]
- starlite.types.LifeSpanSend#
alias of
Callable
[[Union
[LifeSpanStartupCompleteEvent
,LifeSpanStartupFailedEvent
,LifeSpanShutdownCompleteEvent
,LifeSpanShutdownFailedEvent
]],Awaitable
[None
]]
Send / Receive Parameter Types#
- starlite.types.Message#
alias of
Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]
- starlite.types.ReceiveMessage#
alias of
Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]
Helper Types#
Helper types are useful generic types that can be used.
Protocols#
Composite Types#
- starlite.types.ExceptionHandlersMap#
alias of
Dict
[Union
[int
,Type
[Exception
]],Callable
[[Any
,_ExceptionT
],Any
]]
- starlite.types.Middleware#
alias of
Union
[Callable
[[…],Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]]],Any
,Iterator
[Tuple
[Callable
[[Union
[HTTPScope
,WebSocketScope
],Callable
[[…],Awaitable
[Union
[HTTPRequestEvent
,HTTPDisconnectEvent
,WebSocketConnectEvent
,WebSocketReceiveEvent
,WebSocketDisconnectEvent
]]],Callable
[[Union
[HTTPResponseStartEvent
,HTTPResponseBodyEvent
,HTTPServerPushEvent
,HTTPDisconnectEvent
,WebSocketAcceptEvent
,WebSocketSendEvent
,WebSocketResponseStartEvent
,WebSocketResponseBodyEvent
,WebSocketCloseEvent
]],Awaitable
[None
]]],Awaitable
[None
]],Dict
[str
,Any
]]],Type
[Any
]]
Partial types#
- class starlite.types.Partial#
Bases:
Generic
[T
]Type generation for PATCH routes.
Partial is a special typing helper that takes a generic T, which must be a
TypedDict
, dataclass or pydantic model class, and returns to static type checkers a version of this T in which all fields - and nested fields - are optional.
File types#
- class starlite.types.FileInfo#
Bases:
TypedDict
File information gathered from a file system.
- class starlite.types.FileSystemProtocol#
Bases:
Protocol
Base protocol used to interact with a file-system.
This protocol is commensurable with the file systems exported by the [fsspec](https://filesystem-spec.readthedocs.io/en/latest/) library.
- __init__(*args, **kwargs)#
- info(path: PathType, **kwargs: Any) Union[FileInfo, Awaitable[FileInfo]] #
Retrieve information about a given file path.
- Parameters:
path – A file path.
**kwargs – Any additional kwargs.
- Returns:
A dictionary of file info.
- open(file: PathType, mode: OpenBinaryMode, buffering: int = -1) Union[IO[bytes], Awaitable['AsyncFile[bytes]']] #
- open(file: PathType, mode: OpenTextMode, buffering: int = -1) Union[IO[str], Awaitable['AsyncFile[str]']]
Return a file-like object from the filesystem.
Notes
The return value must function correctly in a context
with
block.
- Parameters:
file – Path to the target file.
mode – Mode, similar to the built
open
.buffering – Buffer size.