types

Callable types

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 sys.getdefaultencoding(). errors defaults to 'strict'.

litestar.types.AfterRequestHookHandler = 'AsyncAfterRequestHookHandler | SyncAfterRequestHookHandler'

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 sys.getdefaultencoding(). errors defaults to 'strict'.

litestar.types.AfterResponseHookHandler = 'AsyncAfterResponseHookHandler | SyncAfterResponseHookHandler'

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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). errors defaults to 'strict'.

litestar.types.Guard = 'AsyncGuard | SyncGuard'

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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). 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 sys.getdefaultencoding(). errors defaults to 'strict'.

litestar.types.Serializer

Callable[[Any], Any] 的別名

ASGI Types

litestar.types.Method

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

ASGI Application

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 Application Parameters

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 Scopes

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 Events

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.

Event Groupings

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]] 的別名

Send / Receive Parameter Types

litestar.types.Message

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

litestar.types.ReceiveMessage

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

Helper Types

Helper types are useful generic types that can be used.

litestar.types.SyncOrAsyncUnion

T | Awaitable[T] 的別名

litestar.types.AnyIOBackend

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

litestar.types.OptionalSequence

Sequence[T] | None 的別名

Protocols

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)

Composite Types

litestar.types.Dependencies

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

litestar.types.ExceptionHandlersMap

MutableMapping[Union[int, type[Exception]], ExceptionHandler] 的別名

litestar.types.Middleware

Callable[[...], ASGIApp] 的別名

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 sys.getdefaultencoding(). 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] 的別名