类型

可调用类型

litestar.types.AfterExceptionHookHandler = 'Callable[[ExceptionT, Scope], SyncOrAsyncUnion[None]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.AfterRequestHookHandler = 'Callable[[ASGIApp], SyncOrAsyncUnion[ASGIApp]] | Callable[[Response], SyncOrAsyncUnion[Response]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.AfterResponseHookHandler = 'Callable[[Request], SyncOrAsyncUnion[None]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.AnyCallable

Callable[[...], Any] 的别名

litestar.types.AsyncAnyCallable

Callable[[...], Awaitable[Any]] 的别名

litestar.types.BeforeMessageSendHookHandler = 'Callable[[Message, Scope], SyncOrAsyncUnion[None]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.BeforeRequestHookHandler = 'Callable[[Request], Any | Awaitable[Any]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.CacheKeyBuilder = 'Callable[[Request], str]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.ExceptionHandler = 'Callable[[Request, ExceptionT], Response]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.Guard = 'Callable[[ASGIConnection, BaseRouteHandler], SyncOrAsyncUnion[None]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.LifespanHook = 'Callable[[Litestar], SyncOrAsyncUnion[Any]] | Callable[[], SyncOrAsyncUnion[Any]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.OnAppInitHandler = 'Callable[[AppConfig], AppConfig]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.Serializer

Callable[[Any], Any] 的别名

ASGI 类型

litestar.types.Method

Literal['GET', 'POST', 'DELETE', 'PATCH', 'PUT', 'HEAD', 'TRACE', 'OPTIONS'] | HttpMethod 的别名

ASGI 应用程序

litestar.types.ASGIApp

Callable[[HTTPScope | WebSocketScope, Callable[[...], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent]], Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPServerPushEvent | HTTPDisconnectEvent | WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent], Awaitable[None]]], Awaitable[None]] 的别名

ASGI 应用程序参数

litestar.types.Scope

HTTPScope | WebSocketScope 的别名

litestar.types.Receive

Callable[[...], Awaitable[HTTPRequestEvent | HTTPDisconnectEvent | WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent]] 的别名

litestar.types.Send

Callable[[HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPServerPushEvent | HTTPDisconnectEvent | WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent], Awaitable[None]] 的别名

ASGI 作用域

class litestar.types.ASGIVersion

基类:TypedDict

ASGI spec version.

class litestar.types.BaseScope

基类:HeaderScope

Base ASGI-scope.

class litestar.types.HTTPScope

基类:BaseScope

HTTP-ASGI-scope.

class litestar.types.LifeSpanScope

基类:TypedDict

Lifespan-ASGI-scope.

class litestar.types.WebSocketScope

基类:BaseScope

WebSocket-ASGI-scope.

ASGI 事件

class litestar.types.HTTPRequestEvent

基类:TypedDict

ASGI http.request event.

class litestar.types.HTTPResponseStartEvent

基类:HeaderScope

ASGI http.response.start event.

class litestar.types.HTTPResponseBodyEvent

基类:TypedDict

ASGI http.response.body event.

class litestar.types.HTTPServerPushEvent

基类:HeaderScope

ASGI http.response.push event.

class litestar.types.HTTPDisconnectEvent

基类:TypedDict

ASGI http.disconnect event.

class litestar.types.WebSocketConnectEvent

基类:TypedDict

ASGI websocket.connect event.

class litestar.types.WebSocketAcceptEvent

基类:HeaderScope

ASGI websocket.accept event.

class litestar.types.WebSocketReceiveEvent

基类:TypedDict

ASGI websocket.receive event.

class litestar.types.WebSocketSendEvent

基类:TypedDict

ASGI websocket.send event.

class litestar.types.WebSocketResponseStartEvent

基类:HeaderScope

ASGI websocket.http.response.start event.

class litestar.types.WebSocketResponseBodyEvent

基类:TypedDict

ASGI websocket.http.response.body event.

class litestar.types.WebSocketDisconnectEvent

基类:TypedDict

ASGI websocket.disconnect event.

class litestar.types.WebSocketCloseEvent

基类:TypedDict

ASGI websocket.close event.

class litestar.types.LifeSpanStartupEvent

基类:TypedDict

ASGI lifespan.startup event.

class litestar.types.LifeSpanShutdownEvent

基类:TypedDict

ASGI lifespan.shutdown event.

class litestar.types.LifeSpanStartupCompleteEvent

基类:TypedDict

ASGI lifespan.startup.complete event.

class litestar.types.LifeSpanStartupFailedEvent

基类:TypedDict

ASGI lifespan.startup.failed event.

class litestar.types.LifeSpanShutdownCompleteEvent

基类:TypedDict

ASGI lifespan.shutdown.complete event.

class litestar.types.LifeSpanShutdownFailedEvent

基类:TypedDict

ASGI lifespan.shutdown.failed event.

事件分组

litestar.types.HTTPReceiveMessage

HTTPRequestEvent | HTTPDisconnectEvent 的别名

litestar.types.WebSocketReceiveMessage

WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent 的别名

litestar.types.LifeSpanReceiveMessage

LifeSpanStartupEvent | LifeSpanShutdownEvent 的别名

litestar.types.HTTPSendMessage

HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPServerPushEvent | HTTPDisconnectEvent 的别名

litestar.types.WebSocketSendMessage

WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent 的别名

litestar.types.LifeSpanSendMessage

LifeSpanStartupCompleteEvent | LifeSpanStartupFailedEvent | LifeSpanShutdownCompleteEvent | LifeSpanShutdownFailedEvent 的别名

litestar.types.LifeSpanReceive

Callable[[...], Awaitable[LifeSpanStartupEvent | LifeSpanShutdownEvent]] 的别名

litestar.types.LifeSpanSend

Callable[[LifeSpanStartupCompleteEvent | LifeSpanStartupFailedEvent | LifeSpanShutdownCompleteEvent | LifeSpanShutdownFailedEvent], Awaitable[None]] 的别名

发送/接收参数类型

litestar.types.Message

HTTPResponseStartEvent | HTTPResponseBodyEvent | HTTPServerPushEvent | HTTPDisconnectEvent | WebSocketAcceptEvent | WebSocketSendEvent | WebSocketResponseStartEvent | WebSocketResponseBodyEvent | WebSocketCloseEvent 的别名

litestar.types.ReceiveMessage

HTTPRequestEvent | HTTPDisconnectEvent | WebSocketConnectEvent | WebSocketReceiveEvent | WebSocketDisconnectEvent 的别名

辅助类型

辅助类型是可以使用的有用的泛型类型。

litestar.types.SyncOrAsyncUnion

T | Awaitable[T] 的别名

litestar.types.AnyIOBackend

Literal['asyncio', 'trio'] 的别名

litestar.types.OptionalSequence

Sequence[T] | None 的别名

协议

class litestar.types.Logger

基类:Protocol

Logger protocol.

debug(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'DEBUG' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

info(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'INFO' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

warning(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'WARNING' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

warn(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'WARN' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

error(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'ERROR' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

fatal(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'FATAL' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

exception(event: str, *args: Any, **kwargs: Any) Any

Log a message with level 'ERROR' on this logger. The arguments are interpreted as for debug(). Exception info is added to the logging message.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

critical(event: str, *args: Any, **kwargs: Any) Any

Output a log message at 'INFO' level.

参数:
  • event -- Log message.

  • *args -- Any args.

  • **kwargs -- Any kwargs.

setLevel(level: int) None

Set the log level

参数:

level -- Log level to set as an integer

返回:

None

__init__(*args, **kwargs)

复合类型

litestar.types.Dependencies

Mapping[str, Union[Provide, AnyCallable]] 的别名

litestar.types.ExceptionHandlersMap

MutableMapping[Union[int, Type[Exception]], ExceptionHandler] 的别名

litestar.types.Middleware = 'Union[Callable[..., ASGIApp], DefineMiddleware, Iterator[Tuple[ASGIApp, Dict[str, Any]]], Type[MiddlewareProtocol]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.ResponseCookies

Union[Sequence[Cookie], Mapping[str, str]] 的别名

litestar.types.ResponseHeaders

Union[Sequence[ResponseHeader], Mapping[str, str]] 的别名

litestar.types.PathType

Union[Path, PathLike, str] 的别名

litestar.types.Scopes = 'set[Literal[ScopeType.HTTP, ScopeType.WEBSOCKET]]'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

litestar.types.TypeEncodersMap

Mapping[Any, Callable[[Any], Any]] 的别名

litestar.types.TypeDecodersSequence

Sequence[tuple[Callable[[Any], bool], Callable[[Any, Any], Any]]] 的别名

litestar.types.ParametersMap

Mapping[str, ParameterKwarg] 的别名