├── .all-contributorsrc
├── .devcontainer
├── Dockerfile
└── devcontainer.json
├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── BUG.yml
│ ├── DOCS.yml
│ ├── REQUEST.yml
│ └── config.yml
├── PULL_REQUEST_TEMPLATE.md
├── dependabot.yml
├── labeler.yml
└── workflows
│ ├── ci.yml
│ ├── codeql.yml
│ ├── docs-preview.yml
│ ├── docs.yml
│ ├── notify-released-issues.yml
│ ├── notify_released_issues
│ ├── get_closed_issues.py
│ └── notify.js
│ ├── pr-labeler.yml
│ ├── pr-merged.yml
│ ├── pr-title.yml
│ ├── publish.yml
│ └── test.yml
├── .gitignore
├── .pre-commit-config.yaml
├── CITATION.cff
├── CONTRIBUTING.rst
├── LICENSE
├── Makefile
├── README.md
├── codecov.yml
├── docs
├── PYPI_README.md
├── _static
│ ├── style.css
│ ├── versioning.js
│ └── versions.json
├── admonitions
│ └── sync-to-thread-info.rst
├── benchmarks.rst
├── conf.py
├── contribution-guide.rst
├── examples
│ ├── __init__.py
│ ├── application_hooks
│ │ ├── __init__.py
│ │ ├── after_exception_hook.py
│ │ ├── before_send_hook.py
│ │ ├── lifespan_manager.py
│ │ └── on_app_init.py
│ ├── application_state
│ │ ├── __init__.py
│ │ ├── passing_initial_state.py
│ │ ├── using_application_state.py
│ │ ├── using_custom_state.py
│ │ └── using_immutable_state.py
│ ├── caching
│ │ ├── __init__.py
│ │ ├── cache.py
│ │ ├── cache_response_filter.py
│ │ ├── key_builder.py
│ │ ├── key_builder_for_route_handler.py
│ │ └── redis_store.py
│ ├── channels
│ │ ├── create_route_handlers.py
│ │ ├── create_route_handlers_send_history.py
│ │ ├── iter_stream.py
│ │ ├── put_history.py
│ │ └── run_in_background.py
│ ├── contrib
│ │ ├── __init__.py
│ │ ├── piccolo
│ │ │ ├── __init__.py
│ │ │ ├── app.py
│ │ │ └── piccolo_conf.py
│ │ └── sqlalchemy
│ │ │ ├── __init__.py
│ │ │ ├── plugins
│ │ │ ├── __init__.py
│ │ │ ├── sqlalchemy_async_before_send_handler.py
│ │ │ ├── sqlalchemy_async_dependencies.py
│ │ │ ├── sqlalchemy_async_init_plugin_example.py
│ │ │ ├── sqlalchemy_async_plugin_example.py
│ │ │ ├── sqlalchemy_async_serialization_dto.py
│ │ │ ├── sqlalchemy_async_serialization_plugin.py
│ │ │ ├── sqlalchemy_async_serialization_plugin_marking_fields.py
│ │ │ ├── sqlalchemy_sync_before_send_handler.py
│ │ │ ├── sqlalchemy_sync_dependencies.py
│ │ │ ├── sqlalchemy_sync_init_plugin_example.py
│ │ │ ├── sqlalchemy_sync_plugin_example.py
│ │ │ ├── sqlalchemy_sync_serialization_plugin.py
│ │ │ ├── sqlalchemy_sync_serialization_plugin_marking_fields.py
│ │ │ └── tutorial
│ │ │ │ ├── __init__.py
│ │ │ │ ├── full_app_no_plugins.py
│ │ │ │ ├── full_app_with_init_plugin.py
│ │ │ │ ├── full_app_with_plugin.py
│ │ │ │ ├── full_app_with_serialization_plugin.py
│ │ │ │ └── full_app_with_session_di.py
│ │ │ ├── sqlalchemy_async_repository.py
│ │ │ ├── sqlalchemy_declarative_models.py
│ │ │ ├── sqlalchemy_repository_bulk_operations.py
│ │ │ ├── sqlalchemy_repository_crud.py
│ │ │ ├── sqlalchemy_repository_extension.py
│ │ │ ├── sqlalchemy_sync_repository.py
│ │ │ └── us_state_lookup.json
│ ├── data_transfer_objects
│ │ ├── __init__.py
│ │ ├── defining_dtos_on_layers.py
│ │ ├── factory
│ │ │ ├── __init__.py
│ │ │ ├── dto_data_problem_statement.py
│ │ │ ├── dto_data_usage.py
│ │ │ ├── enveloping_return_data.py
│ │ │ ├── excluding_fields.py
│ │ │ ├── included_fields.py
│ │ │ ├── leading_underscore_private.py
│ │ │ ├── leading_underscore_private_override.py
│ │ │ ├── marking_fields.py
│ │ │ ├── my_lib.py
│ │ │ ├── paginated_return_data.py
│ │ │ ├── patch_requests.py
│ │ │ ├── providing_values_for_nested_data.py
│ │ │ ├── related_items.py
│ │ │ ├── renaming_all_fields.py
│ │ │ ├── renaming_fields.py
│ │ │ ├── response_return_data.py
│ │ │ ├── simple_dto_factory_example.py
│ │ │ ├── tutorial
│ │ │ │ ├── __init__.py
│ │ │ │ ├── controller.py
│ │ │ │ ├── dto_data.py
│ │ │ │ ├── explicit_field_renaming.py
│ │ │ │ ├── field_renaming_strategy.py
│ │ │ │ ├── initial_pattern.py
│ │ │ │ ├── max_nested_depth.py
│ │ │ │ ├── multiple_handlers.py
│ │ │ │ ├── nested_collection_exclude.py
│ │ │ │ ├── nested_exclude.py
│ │ │ │ ├── patch_handlers.py
│ │ │ │ ├── put_handlers.py
│ │ │ │ ├── read_only_fields_error.py
│ │ │ │ ├── simple_dto_exclude.py
│ │ │ │ └── simple_receiving_data.py
│ │ │ ├── type_checking.py
│ │ │ └── unknown_fields.py
│ │ ├── models.py
│ │ ├── overriding_implicit_return_dto.py
│ │ ├── the_dto_parameter.py
│ │ └── the_return_dto_parameter.py
│ ├── datastructures
│ │ ├── __init__.py
│ │ ├── headers
│ │ │ ├── __init__.py
│ │ │ ├── cache_control.py
│ │ │ ├── etag.py
│ │ │ └── etag_parsing.py
│ │ └── secrets
│ │ │ ├── __init__.py
│ │ │ ├── secret_body.py
│ │ │ └── secret_header.py
│ ├── dependency_injection
│ │ ├── __init__.py
│ │ ├── dependency_non_optional_not_provided.py
│ │ ├── dependency_skip_validation.py
│ │ ├── dependency_validation_error.py
│ │ ├── dependency_with_default.py
│ │ ├── dependency_with_dependency_fn_and_default.py
│ │ ├── dependency_yield_exceptions.py
│ │ └── dependency_yield_simple.py
│ ├── deployment
│ │ └── nginx-unit
│ │ │ ├── install-macos.sh
│ │ │ └── unit.json
│ ├── encoding_decoding
│ │ ├── __init__.py
│ │ ├── custom_type_encoding_decoding.py
│ │ └── custom_type_pydantic.py
│ ├── exceptions
│ │ ├── __init__.py
│ │ ├── implicit_media_type.py
│ │ ├── layered_handlers.py
│ │ ├── override_default_handler.py
│ │ └── per_exception_handlers.py
│ ├── hello_world.py
│ ├── lifecycle_hooks
│ │ ├── __init__.py
│ │ ├── after_request.py
│ │ ├── after_response.py
│ │ ├── before_request.py
│ │ └── layered_hooks.py
│ ├── middleware
│ │ ├── __init__.py
│ │ ├── abstract_middleware_migration_new.py
│ │ ├── abstract_middleware_migration_old.py
│ │ ├── base.py
│ │ ├── call_order.py
│ │ ├── logging_middleware.py
│ │ ├── middleware_protocol_migration_new.py
│ │ ├── middleware_protocol_migration_old.py
│ │ ├── rate_limit.py
│ │ ├── request_timing.py
│ │ ├── session
│ │ │ ├── __init__.py
│ │ │ ├── cookie_backend.py
│ │ │ ├── cookies_full_example.py
│ │ │ └── file_store.py
│ │ └── using_asgi_middleware.py
│ ├── openapi
│ │ ├── __init__.py
│ │ ├── customize_operation_class.py
│ │ ├── customize_path.py
│ │ ├── customize_pydantic_model_name.py
│ │ └── plugins
│ │ │ ├── __init__.py
│ │ │ ├── custom_plugin.py
│ │ │ ├── rapidoc_config.py
│ │ │ ├── rapidoc_simple.py
│ │ │ ├── receive_router.py
│ │ │ ├── redoc_config.py
│ │ │ ├── redoc_simple.py
│ │ │ ├── scalar_config.py
│ │ │ ├── scalar_customized.py
│ │ │ ├── scalar_simple.py
│ │ │ ├── serving_multiple_uis.py
│ │ │ ├── stoplight_config.py
│ │ │ ├── stoplight_simple.py
│ │ │ ├── swagger_ui_config.py
│ │ │ ├── swagger_ui_oauth.py
│ │ │ ├── swagger_ui_simple.py
│ │ │ └── yaml_simple.py
│ ├── pagination
│ │ ├── __init__.py
│ │ ├── using_classic_pagination.py
│ │ ├── using_cursor_pagination.py
│ │ ├── using_offset_pagination.py
│ │ └── using_offset_pagination_with_sqlalchemy.py
│ ├── parameters
│ │ ├── __init__.py
│ │ ├── header_and_cookie_parameters.py
│ │ ├── layered_parameters.py
│ │ ├── path_parameters_1.py
│ │ ├── path_parameters_2.py
│ │ ├── path_parameters_3.py
│ │ ├── query_params.py
│ │ ├── query_params_constraints.py
│ │ ├── query_params_default.py
│ │ ├── query_params_optional.py
│ │ ├── query_params_remap.py
│ │ └── query_params_types.py
│ ├── plugins
│ │ ├── __init__.py
│ │ ├── di_plugin.py
│ │ ├── flash_messages
│ │ │ ├── __init__.py
│ │ │ ├── jinja.py
│ │ │ ├── mako.py
│ │ │ ├── minijinja.py
│ │ │ └── usage.py
│ │ ├── init_plugin_protocol.py
│ │ ├── problem_details
│ │ │ ├── basic_usage.py
│ │ │ ├── convert_exceptions.py
│ │ │ └── convert_http_exceptions.py
│ │ ├── prometheus
│ │ │ ├── __init__.py
│ │ │ ├── using_prometheus_exporter.py
│ │ │ └── using_prometheus_exporter_with_extra_configs.py
│ │ ├── sqlalchemy
│ │ │ ├── configure.py
│ │ │ └── modelling.py
│ │ └── sqlalchemy_init_plugin
│ │ │ ├── __init__.py
│ │ │ ├── sqlalchemy_async.py
│ │ │ └── sqlalchemy_sync.py
│ ├── request_data
│ │ ├── __init__.py
│ │ ├── custom_request.py
│ │ ├── msgpack_request.py
│ │ ├── request_data_1.py
│ │ ├── request_data_10.py
│ │ ├── request_data_2.py
│ │ ├── request_data_3.py
│ │ ├── request_data_4.py
│ │ ├── request_data_5.py
│ │ ├── request_data_6.py
│ │ ├── request_data_7.py
│ │ ├── request_data_8.py
│ │ └── request_data_9.py
│ ├── responses
│ │ ├── __init__.py
│ │ ├── background_tasks_1.py
│ │ ├── background_tasks_2.py
│ │ ├── background_tasks_3.py
│ │ ├── custom_responses.py
│ │ ├── json_suffix_responses.py
│ │ ├── response_content.py
│ │ ├── response_cookies_1.py
│ │ ├── response_cookies_2.py
│ │ ├── response_cookies_3.py
│ │ ├── response_cookies_4.py
│ │ ├── response_cookies_5.py
│ │ ├── response_headers_1.py
│ │ ├── response_headers_2.py
│ │ ├── response_headers_3.py
│ │ ├── response_headers_4.py
│ │ ├── returning_responses.py
│ │ ├── sse_responses.py
│ │ └── streaming_responses.py
│ ├── routing
│ │ ├── __init__.py
│ │ ├── mount_custom_app.py
│ │ └── mounting_starlette_app.py
│ ├── security
│ │ ├── __init__.py
│ │ ├── guards.py
│ │ ├── jwt
│ │ │ ├── __init__.py
│ │ │ ├── custom_decode_payload.py
│ │ │ ├── custom_token_cls.py
│ │ │ ├── using_jwt_auth.py
│ │ │ ├── using_jwt_cookie_auth.py
│ │ │ ├── using_oauth2_password_bearer.py
│ │ │ ├── using_token_revocation.py
│ │ │ └── verify_issuer_audience.py
│ │ ├── using_abstract_authentication_middleware.py
│ │ └── using_session_auth.py
│ ├── signature_namespace
│ │ ├── __init__.py
│ │ ├── app.py
│ │ ├── controller.py
│ │ └── domain.py
│ ├── startup_and_shutdown.py
│ ├── static_files
│ │ ├── __init__.py
│ │ ├── custom_router.py
│ │ ├── file_system.py
│ │ ├── full_example.py
│ │ ├── html_mode.py
│ │ ├── passing_options.py
│ │ ├── route_reverse.py
│ │ ├── send_as_attachment.py
│ │ ├── upgrade_from_static_1.py
│ │ └── upgrade_from_static_2.py
│ ├── stores
│ │ ├── __init__.py
│ │ ├── configure_integrations_set_names.py
│ │ ├── delete_expired_after_response.py
│ │ ├── delete_expired_on_startup.py
│ │ ├── expiry.py
│ │ ├── expiry_renew_on_get.py
│ │ ├── get_set.py
│ │ ├── namespacing.py
│ │ ├── registry.py
│ │ ├── registry_access_integration.py
│ │ ├── registry_configure_integrations.py
│ │ ├── registry_default_factory.py
│ │ └── registry_default_factory_namespacing.py
│ ├── templating
│ │ ├── __init__.py
│ │ ├── engine_instance_jinja.py
│ │ ├── engine_instance_mako.py
│ │ ├── engine_instance_minijinja.py
│ │ ├── returning_templates_jinja.py
│ │ ├── returning_templates_mako.py
│ │ ├── returning_templates_minijinja.py
│ │ ├── template_engine_jinja.py
│ │ ├── template_engine_mako.py
│ │ ├── template_engine_minijinja.py
│ │ ├── template_functions_jinja.py
│ │ ├── template_functions_mako.py
│ │ ├── template_functions_minijinja.py
│ │ └── templates
│ │ │ ├── hello.html.jinja2
│ │ │ ├── hello.html.mako
│ │ │ ├── hello.html.minijinja
│ │ │ ├── index.html.jinja2
│ │ │ ├── index.html.mako
│ │ │ └── index.html.minijinja
│ ├── testing
│ │ ├── __init__.py
│ │ ├── subprocess_sse_app.py
│ │ ├── test_get_session_data.py
│ │ ├── test_get_session_data_async.py
│ │ ├── test_health_check_async.py
│ │ ├── test_health_check_sync.py
│ │ ├── test_set_session_data.py
│ │ ├── test_set_session_data_async.py
│ │ ├── test_subprocess_sse.py
│ │ ├── test_websocket.py
│ │ └── test_with_portal.py
│ ├── todo_app
│ │ ├── __init__.py
│ │ ├── create
│ │ │ ├── __init__.py
│ │ │ ├── dataclass.py
│ │ │ └── dict.py
│ │ ├── full_app.py
│ │ ├── get_list
│ │ │ ├── __init__.py
│ │ │ ├── dataclass.py
│ │ │ ├── dict.py
│ │ │ ├── query_param.py
│ │ │ ├── query_param_default.py
│ │ │ ├── query_param_validate.py
│ │ │ └── query_param_validate_manually.py
│ │ ├── hello_world.py
│ │ └── update.py
│ └── websockets
│ │ ├── __init__.py
│ │ ├── custom_websocket.py
│ │ ├── dependency_injection_simple.py
│ │ ├── dependency_injection_yield.py
│ │ ├── listener_class_based.py
│ │ ├── listener_class_based_async.py
│ │ ├── mode_receive_binary.py
│ │ ├── mode_receive_text.py
│ │ ├── mode_send_binary.py
│ │ ├── mode_send_text.py
│ │ ├── receive_bytes.py
│ │ ├── receive_json.py
│ │ ├── receive_str.py
│ │ ├── sending_bytes.py
│ │ ├── sending_json_dataclass.py
│ │ ├── sending_json_dict.py
│ │ ├── sending_str.py
│ │ ├── setting_custom_connection_headers.py
│ │ ├── socket_access.py
│ │ ├── stream_and_receive_listener.py
│ │ ├── stream_and_receive_raw.py
│ │ ├── stream_basic.py
│ │ ├── stream_di_hog.py
│ │ ├── stream_di_hog_fix.py
│ │ ├── stream_socket_access.py
│ │ └── with_dto.py
├── images
│ ├── benchmarks
│ │ ├── rps_dependency-injection.svg
│ │ ├── rps_files.svg
│ │ ├── rps_json.svg
│ │ ├── rps_params.svg
│ │ ├── rps_plaintext.svg
│ │ └── rps_serialization.svg
│ ├── cli
│ │ ├── litestar_info.png
│ │ └── litestar_routes.png
│ ├── debugging
│ │ ├── pycharm-config-cli.png
│ │ ├── pycharm-config-uvicorn.png
│ │ ├── pycharm-debug.png
│ │ ├── vs-code-add-config.png
│ │ ├── vs-code-config-litestar.png
│ │ ├── vs-code-debug.png
│ │ └── vs-code-select-config.png
│ ├── examples
│ │ └── template_engine_callable.png
│ └── exception-handlers.jpg
├── index.rst
├── migration
│ ├── fastapi.rst
│ ├── flask.rst
│ └── index.rst
├── reference
│ ├── app.rst
│ ├── background_tasks.rst
│ ├── channels
│ │ ├── backends
│ │ │ ├── asyncpg.rst
│ │ │ ├── base.rst
│ │ │ ├── index.rst
│ │ │ ├── memory.rst
│ │ │ ├── psycopg.rst
│ │ │ └── redis.rst
│ │ ├── index.rst
│ │ ├── plugin.rst
│ │ └── subscriber.rst
│ ├── cli.rst
│ ├── concurrency.rst
│ ├── config.rst
│ ├── connection.rst
│ ├── contrib
│ │ ├── htmx.rst
│ │ ├── index.rst
│ │ ├── jinja.rst
│ │ ├── jwt.rst
│ │ ├── mako.rst
│ │ ├── opentelemetry.rst
│ │ ├── piccolo.rst
│ │ ├── pydantic.rst
│ │ ├── repository
│ │ │ ├── abc.rst
│ │ │ ├── exceptions.rst
│ │ │ ├── filters.rst
│ │ │ ├── handlers.rst
│ │ │ └── testing.rst
│ │ └── sqlalchemy
│ │ │ ├── base.rst
│ │ │ ├── dto.rst
│ │ │ ├── index.rst
│ │ │ ├── plugins.rst
│ │ │ ├── repository.rst
│ │ │ └── types.rst
│ ├── controller.rst
│ ├── data_extractors.rst
│ ├── datastructures
│ │ ├── index.rst
│ │ └── secret_values.rst
│ ├── di.rst
│ ├── dto
│ │ ├── base_dto.rst
│ │ ├── config.rst
│ │ ├── data_structures.rst
│ │ ├── dataclass_dto.rst
│ │ ├── field.rst
│ │ ├── index.rst
│ │ ├── msgspec_dto.rst
│ │ └── types.rst
│ ├── enums.rst
│ ├── events.rst
│ ├── exceptions.rst
│ ├── handlers.rst
│ ├── index.rst
│ ├── logging
│ │ ├── config.rst
│ │ ├── index.rst
│ │ ├── picologging.rst
│ │ └── standard.rst
│ ├── middleware
│ │ ├── allowed_hosts.rst
│ │ ├── authentication.rst
│ │ ├── compression.rst
│ │ ├── cors.rst
│ │ ├── csrf.rst
│ │ ├── index.rst
│ │ ├── logging.rst
│ │ ├── rate_limit.rst
│ │ └── session
│ │ │ ├── base.rst
│ │ │ ├── client_side.rst
│ │ │ ├── index.rst
│ │ │ └── server_side.rst
│ ├── openapi
│ │ ├── index.rst
│ │ ├── openapi.rst
│ │ ├── plugins.rst
│ │ └── spec.rst
│ ├── pagination.rst
│ ├── params.rst
│ ├── plugins
│ │ ├── attrs.rst
│ │ ├── flash_messages.rst
│ │ ├── htmx.rst
│ │ ├── index.rst
│ │ ├── problem_details.rst
│ │ ├── prometheus.rst
│ │ ├── pydantic.rst
│ │ ├── sqlalchemy.rst
│ │ └── structlog.rst
│ ├── repository
│ │ ├── abc.rst
│ │ ├── exceptions.rst
│ │ ├── filters.rst
│ │ ├── handlers.rst
│ │ ├── index.rst
│ │ └── testing.rst
│ ├── response
│ │ ├── base.rst
│ │ ├── file.rst
│ │ ├── index.rst
│ │ ├── redirect.rst
│ │ ├── sse.rst
│ │ ├── streaming.rst
│ │ └── template.rst
│ ├── router.rst
│ ├── routes.rst
│ ├── security
│ │ ├── index.rst
│ │ ├── jwt.rst
│ │ └── session_auth.rst
│ ├── serialization.rst
│ ├── static_files.rst
│ ├── status_codes.rst
│ ├── stores
│ │ ├── base.rst
│ │ ├── file.rst
│ │ ├── index.rst
│ │ ├── memory.rst
│ │ ├── redis.rst
│ │ ├── registry.rst
│ │ └── valkey.rst
│ ├── template.rst
│ ├── testing.rst
│ ├── types.rst
│ └── typing.rst
├── release-notes
│ ├── changelog.rst
│ ├── index.rst
│ └── whats-new-2.rst
├── topics
│ ├── deployment
│ │ ├── docker.rst
│ │ ├── index.rst
│ │ ├── manually-with-asgi-server.rst
│ │ ├── nginx-unit.rst
│ │ └── supervisor.rst
│ ├── index.rst
│ └── sync-vs-async.rst
├── tutorials
│ ├── dto-tutorial
│ │ ├── 01-simple-dto-exclude.rst
│ │ ├── 02-nested-exclude.rst
│ │ ├── 03-nested-collection-exclude.rst
│ │ ├── 04-max-nested-depth.rst
│ │ ├── 05-renaming-fields.rst
│ │ ├── 06-receiving-data.rst
│ │ ├── 07-read-only-fields.rst
│ │ ├── 08-dto-data.rst
│ │ ├── 09-updating.rst
│ │ ├── 10-layered-dto-declarations.rst
│ │ ├── images
│ │ │ ├── dto_data.png
│ │ │ ├── explicit_field_renaming.png
│ │ │ ├── field_renaming_strategy.png
│ │ │ ├── initial_pattern.png
│ │ │ ├── max_nested_depth.png
│ │ │ ├── nested_collection_exclude.png
│ │ │ ├── nested_exclude.png
│ │ │ ├── patch_handlers.png
│ │ │ ├── put_handlers.png
│ │ │ ├── read_only_fields_error.png
│ │ │ ├── simple_exclude.png
│ │ │ └── simple_receive_data.png
│ │ └── index.rst
│ ├── index.rst
│ ├── repository-tutorial
│ │ ├── 01-modelling-and-features.rst
│ │ ├── 02-repository-introduction.rst
│ │ ├── 03-repository-controller.rst
│ │ ├── 04-repository-other.rst
│ │ └── index.rst
│ ├── sqlalchemy
│ │ ├── 0-introduction.rst
│ │ ├── 1-provide-session-with-di.rst
│ │ ├── 2-serialization-plugin.rst
│ │ ├── 3-init-plugin.rst
│ │ ├── 4-final-touches-and-recap.rst
│ │ └── index.rst
│ └── todo-app
│ │ ├── 0-application-basics.rst
│ │ ├── 1-accessing-the-list.rst
│ │ ├── 2-interacting-with-the-list.rst
│ │ ├── 3-assembling-the-app.rst
│ │ ├── images
│ │ ├── done-john-2.png
│ │ ├── done-john.png
│ │ ├── get_todo_list.png
│ │ ├── hello_world.png
│ │ ├── missing-query.png
│ │ ├── swagger-dataclass-bad-body.png
│ │ ├── swagger-dict-vs-dataclass.png
│ │ ├── swagger-failed-validation.png
│ │ ├── swagger-get-example-request.png
│ │ ├── swagger-get.png
│ │ ├── swagger-post-dataclass.png
│ │ ├── swagger-post-dict-response.png
│ │ ├── swagger-post-dict.png
│ │ ├── todos-done.png
│ │ └── todos-not-done.png
│ │ └── index.rst
└── usage
│ ├── applications.rst
│ ├── caching.rst
│ ├── channels.rst
│ ├── cli.rst
│ ├── custom-types.rst
│ ├── databases
│ ├── index.rst
│ ├── piccolo.rst
│ └── sqlalchemy
│ │ ├── index.rst
│ │ ├── models_and_repository.rst
│ │ └── plugins
│ │ ├── index.rst
│ │ ├── sqlalchemy_init_plugin.rst
│ │ ├── sqlalchemy_plugin.rst
│ │ └── sqlalchemy_serialization_plugin.rst
│ ├── debugging.rst
│ ├── dependency-injection.rst
│ ├── dto
│ ├── 0-basic-use.rst
│ ├── 1-abstract-dto.rst
│ ├── 2-creating-custom-dto-classes.rst
│ └── index.rst
│ ├── events.rst
│ ├── exceptions.rst
│ ├── htmx.rst
│ ├── index.rst
│ ├── lifecycle-hooks.rst
│ ├── logging.rst
│ ├── metrics
│ ├── index.rst
│ ├── open-telemetry.rst
│ └── prometheus.rst
│ ├── middleware
│ ├── builtin-middleware.rst
│ ├── creating-middleware.rst
│ ├── index.rst
│ └── using-middleware.rst
│ ├── openapi
│ ├── index.rst
│ ├── schema_generation.rst
│ └── ui_plugins.rst
│ ├── plugins
│ ├── flash_messages.rst
│ ├── index.rst
│ └── problem_details.rst
│ ├── requests.rst
│ ├── responses.rst
│ ├── routing
│ ├── handlers.rst
│ ├── index.rst
│ ├── overview.rst
│ └── parameters.rst
│ ├── security
│ ├── abstract-authentication-middleware.rst
│ ├── excluding-and-including-endpoints.rst
│ ├── guards.rst
│ ├── index.rst
│ ├── jwt.rst
│ ├── secret-datastructures.rst
│ └── security-backends.rst
│ ├── static-files.rst
│ ├── stores.rst
│ ├── templating.rst
│ ├── testing.rst
│ └── websockets.rst
├── litestar
├── __init__.py
├── __main__.py
├── _asgi
│ ├── __init__.py
│ ├── asgi_router.py
│ ├── routing_trie
│ │ ├── __init__.py
│ │ ├── mapping.py
│ │ ├── traversal.py
│ │ ├── types.py
│ │ └── validate.py
│ └── utils.py
├── _kwargs
│ ├── __init__.py
│ ├── cleanup.py
│ ├── dependencies.py
│ ├── extractors.py
│ ├── kwargs_model.py
│ ├── parameter_definition.py
│ └── types.py
├── _layers
│ ├── __init__.py
│ └── utils.py
├── _multipart.py
├── _openapi
│ ├── __init__.py
│ ├── datastructures.py
│ ├── parameters.py
│ ├── path_item.py
│ ├── plugin.py
│ ├── request_body.py
│ ├── responses.py
│ ├── schema_generation
│ │ ├── __init__.py
│ │ ├── constrained_fields.py
│ │ ├── examples.py
│ │ ├── plugins
│ │ │ ├── __init__.py
│ │ │ ├── dataclass.py
│ │ │ ├── pagination.py
│ │ │ ├── struct.py
│ │ │ └── typed_dict.py
│ │ ├── schema.py
│ │ └── utils.py
│ ├── typescript_converter
│ │ ├── __init__.py
│ │ ├── converter.py
│ │ ├── schema_parsing.py
│ │ └── types.py
│ └── utils.py
├── _parsers.py
├── _signature
│ ├── __init__.py
│ ├── model.py
│ ├── types.py
│ └── utils.py
├── app.py
├── background_tasks.py
├── channels
│ ├── __init__.py
│ ├── backends
│ │ ├── __init__.py
│ │ ├── _redis_flushall_streams.lua
│ │ ├── _redis_pubsub_publish.lua
│ │ ├── _redis_xadd_expire.lua
│ │ ├── asyncpg.py
│ │ ├── base.py
│ │ ├── memory.py
│ │ ├── psycopg.py
│ │ └── redis.py
│ ├── plugin.py
│ └── subscriber.py
├── cli
│ ├── __init__.py
│ ├── _utils.py
│ ├── commands
│ │ ├── __init__.py
│ │ ├── core.py
│ │ ├── schema.py
│ │ └── sessions.py
│ └── main.py
├── concurrency.py
├── config
│ ├── __init__.py
│ ├── allowed_hosts.py
│ ├── app.py
│ ├── compression.py
│ ├── cors.py
│ ├── csrf.py
│ └── response_cache.py
├── connection
│ ├── __init__.py
│ ├── base.py
│ ├── request.py
│ └── websocket.py
├── constants.py
├── contrib
│ ├── __init__.py
│ ├── attrs
│ │ ├── __init__.py
│ │ └── attrs_schema_plugin.py
│ ├── htmx
│ │ ├── __init__.py
│ │ ├── _utils.py
│ │ ├── request.py
│ │ ├── response.py
│ │ └── types.py
│ ├── jinja.py
│ ├── jwt
│ │ ├── __init__.py
│ │ ├── jwt_auth.py
│ │ ├── jwt_token.py
│ │ └── middleware.py
│ ├── mako.py
│ ├── minijinja.py
│ ├── minijnja.py
│ ├── opentelemetry
│ │ ├── __init__.py
│ │ ├── _utils.py
│ │ ├── config.py
│ │ ├── middleware.py
│ │ └── plugin.py
│ ├── piccolo.py
│ ├── prometheus
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── controller.py
│ │ └── middleware.py
│ ├── pydantic
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── pydantic_di_plugin.py
│ │ ├── pydantic_dto_factory.py
│ │ ├── pydantic_init_plugin.py
│ │ ├── pydantic_schema_plugin.py
│ │ └── utils.py
│ ├── repository
│ │ ├── __init__.py
│ │ ├── abc
│ │ │ └── __init__.py
│ │ ├── exceptions.py
│ │ ├── filters.py
│ │ ├── handlers.py
│ │ └── testing.py
│ └── sqlalchemy
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── dto.py
│ │ ├── plugins
│ │ ├── __init__.py
│ │ ├── init
│ │ │ ├── __init__.py
│ │ │ ├── config
│ │ │ │ ├── __init__.py
│ │ │ │ ├── asyncio.py
│ │ │ │ ├── common.py
│ │ │ │ ├── compat.py
│ │ │ │ ├── engine.py
│ │ │ │ └── sync.py
│ │ │ └── plugin.py
│ │ └── serialization.py
│ │ ├── repository
│ │ ├── __init__.py
│ │ ├── _async.py
│ │ ├── _sync.py
│ │ ├── _util.py
│ │ └── types.py
│ │ └── types.py
├── controller.py
├── data_extractors.py
├── datastructures
│ ├── __init__.py
│ ├── cookie.py
│ ├── headers.py
│ ├── multi_dicts.py
│ ├── response_header.py
│ ├── secret_values.py
│ ├── state.py
│ ├── upload_file.py
│ └── url.py
├── di.py
├── dto
│ ├── __init__.py
│ ├── _backend.py
│ ├── _codegen_backend.py
│ ├── _types.py
│ ├── base_dto.py
│ ├── config.py
│ ├── data_structures.py
│ ├── dataclass_dto.py
│ ├── field.py
│ ├── msgspec_dto.py
│ └── types.py
├── enums.py
├── events
│ ├── __init__.py
│ ├── emitter.py
│ └── listener.py
├── exceptions
│ ├── __init__.py
│ ├── base_exceptions.py
│ ├── dto_exceptions.py
│ ├── http_exceptions.py
│ ├── responses
│ │ ├── __init__.py
│ │ ├── _debug_response.py
│ │ └── templates
│ │ │ ├── body.html
│ │ │ ├── frame.html
│ │ │ ├── scripts.js
│ │ │ └── styles.css
│ └── websocket_exceptions.py
├── file_system.py
├── handlers
│ ├── __init__.py
│ ├── asgi_handlers.py
│ ├── base.py
│ ├── http_handlers
│ │ ├── __init__.py
│ │ ├── _utils.py
│ │ ├── base.py
│ │ └── decorators.py
│ └── websocket_handlers
│ │ ├── __init__.py
│ │ ├── _utils.py
│ │ ├── listener.py
│ │ ├── route_handler.py
│ │ └── stream.py
├── logging
│ ├── __init__.py
│ ├── _utils.py
│ ├── config.py
│ ├── picologging.py
│ └── standard.py
├── middleware
│ ├── __init__.py
│ ├── _internal
│ │ ├── __init__.py
│ │ ├── cors.py
│ │ └── exceptions
│ │ │ ├── __init__.py
│ │ │ └── middleware.py
│ ├── _utils.py
│ ├── allowed_hosts.py
│ ├── authentication.py
│ ├── base.py
│ ├── compression
│ │ ├── __init__.py
│ │ ├── brotli_facade.py
│ │ ├── facade.py
│ │ ├── gzip_facade.py
│ │ └── middleware.py
│ ├── cors.py
│ ├── csrf.py
│ ├── exceptions
│ │ ├── __init__.py
│ │ ├── _debug_response.py
│ │ └── middleware.py
│ ├── logging.py
│ ├── rate_limit.py
│ ├── response_cache.py
│ └── session
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── client_side.py
│ │ └── server_side.py
├── openapi
│ ├── __init__.py
│ ├── config.py
│ ├── controller.py
│ ├── datastructures.py
│ ├── plugins.py
│ └── spec
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── callback.py
│ │ ├── components.py
│ │ ├── contact.py
│ │ ├── discriminator.py
│ │ ├── encoding.py
│ │ ├── enums.py
│ │ ├── example.py
│ │ ├── external_documentation.py
│ │ ├── header.py
│ │ ├── info.py
│ │ ├── license.py
│ │ ├── link.py
│ │ ├── media_type.py
│ │ ├── oauth_flow.py
│ │ ├── oauth_flows.py
│ │ ├── open_api.py
│ │ ├── operation.py
│ │ ├── parameter.py
│ │ ├── path_item.py
│ │ ├── paths.py
│ │ ├── reference.py
│ │ ├── request_body.py
│ │ ├── response.py
│ │ ├── responses.py
│ │ ├── schema.py
│ │ ├── security_requirement.py
│ │ ├── security_scheme.py
│ │ ├── server.py
│ │ ├── server_variable.py
│ │ ├── tag.py
│ │ └── xml.py
├── pagination.py
├── params.py
├── plugins
│ ├── __init__.py
│ ├── attrs.py
│ ├── base.py
│ ├── core
│ │ ├── __init__.py
│ │ └── _msgspec.py
│ ├── flash.py
│ ├── htmx.py
│ ├── problem_details.py
│ ├── prometheus
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── controller.py
│ │ └── middleware.py
│ ├── pydantic
│ │ ├── __init__.py
│ │ ├── dto.py
│ │ ├── plugins
│ │ │ ├── __init__.py
│ │ │ ├── di.py
│ │ │ ├── init.py
│ │ │ └── schema.py
│ │ └── utils.py
│ ├── sqlalchemy.py
│ └── structlog.py
├── py.typed
├── repository
│ ├── __init__.py
│ ├── _exceptions.py
│ ├── _filters.py
│ ├── abc
│ │ ├── __init__.py
│ │ ├── _async.py
│ │ └── _sync.py
│ ├── exceptions.py
│ ├── filters.py
│ ├── handlers.py
│ └── testing
│ │ ├── __init__.py
│ │ └── generic_mock_repository.py
├── response
│ ├── __init__.py
│ ├── base.py
│ ├── file.py
│ ├── redirect.py
│ ├── sse.py
│ ├── streaming.py
│ └── template.py
├── router.py
├── routes
│ ├── __init__.py
│ ├── asgi.py
│ ├── base.py
│ ├── http.py
│ └── websocket.py
├── security
│ ├── __init__.py
│ ├── base.py
│ ├── jwt
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ ├── middleware.py
│ │ └── token.py
│ └── session_auth
│ │ ├── __init__.py
│ │ ├── auth.py
│ │ └── middleware.py
├── serialization
│ ├── __init__.py
│ └── msgspec_hooks.py
├── static_files
│ ├── __init__.py
│ ├── base.py
│ └── config.py
├── status_codes.py
├── stores
│ ├── __init__.py
│ ├── base.py
│ ├── file.py
│ ├── memory.py
│ ├── redis.py
│ ├── registry.py
│ └── valkey.py
├── template
│ ├── __init__.py
│ ├── base.py
│ └── config.py
├── testing
│ ├── __init__.py
│ ├── client
│ │ ├── __init__.py
│ │ ├── async_client.py
│ │ ├── base.py
│ │ ├── subprocess_client.py
│ │ └── sync_client.py
│ ├── helpers.py
│ ├── life_span_handler.py
│ ├── request_factory.py
│ ├── transport.py
│ └── websocket_test_session.py
├── types
│ ├── __init__.py
│ ├── asgi_types.py
│ ├── builtin_types.py
│ ├── callable_types.py
│ ├── composite_types.py
│ ├── debugger_types.py
│ ├── empty.py
│ ├── file_types.py
│ ├── helper_types.py
│ ├── internal_types.py
│ ├── protocols.py
│ └── serialization.py
├── typing.py
└── utils
│ ├── __init__.py
│ ├── compat.py
│ ├── dataclass.py
│ ├── deprecation.py
│ ├── empty.py
│ ├── helpers.py
│ ├── module_loader.py
│ ├── path.py
│ ├── predicates.py
│ ├── scope
│ ├── __init__.py
│ └── state.py
│ ├── sequence.py
│ ├── signature.py
│ ├── sync.py
│ ├── typing.py
│ ├── version.py
│ └── warnings.py
├── pyproject.toml
├── test_apps
├── __init__.py
├── asgi_with_starlette_test_app
│ ├── __init__.py
│ └── main.py
├── debugging
│ ├── __init__.py
│ └── main.py
├── logging_test_app
│ ├── __init__.py
│ └── main.py
├── openapi_test_app
│ ├── __init__.py
│ └── main.py
├── piccolo_admin_test_app
│ ├── __init__.py
│ ├── home
│ │ ├── __init__.py
│ │ ├── piccolo_app.py
│ │ ├── piccolo_migrations
│ │ │ └── .gitkeep
│ │ ├── schema.py
│ │ ├── tables.py
│ │ └── templates
│ │ │ └── .gitkeep
│ ├── main.py
│ └── piccolo_conf.py
├── pydantic_1_app.py
├── sse
│ ├── __init__.py
│ ├── sse.html
│ └── sse_empty.py
├── static_files_test_app
│ ├── __init__.py
│ ├── main.py
│ └── public
│ │ └── index.html
└── structlog_app
│ ├── __init__.py
│ └── main.py
├── tests
├── __init__.py
├── conftest.py
├── docker-compose.yml
├── docker_service_fixtures.py
├── e2e
│ ├── __init__.py
│ ├── test_advanced_alchemy.py
│ ├── test_cors
│ │ ├── __init__.py
│ │ ├── test_cors_allowed_headers.py
│ │ ├── test_cors_allowed_methods.py
│ │ ├── test_cors_credentials.py
│ │ ├── test_cors_for_middleware_exception.py
│ │ ├── test_cors_for_mount.py
│ │ ├── test_cors_for_routing_exception.py
│ │ ├── test_cors_origins.py
│ │ ├── test_custom_options_handlers.py
│ │ └── test_non_cors_options.py
│ ├── test_dependency_injection
│ │ ├── __init__.py
│ │ ├── test_dependency_validation.py
│ │ ├── test_http_handler_dependency_injection.py
│ │ ├── test_injection_of_classes.py
│ │ ├── test_injection_of_generic_models.py
│ │ ├── test_inter_dependencies.py
│ │ ├── test_request_local_caching.py
│ │ └── test_websocket_handler_dependency_injection.py
│ ├── test_exception_handlers
│ │ ├── __init__.py
│ │ ├── test_exception_handler_registered_on_handler.py
│ │ └── test_exception_handlers.py
│ ├── test_life_cycle_hooks
│ │ ├── __init__.py
│ │ ├── test_after_request.py
│ │ ├── test_after_response.py
│ │ └── test_before_request.py
│ ├── test_logging
│ │ ├── __init__.py
│ │ └── test_structlog_to_file.py
│ ├── test_middleware
│ │ ├── __init__.py
│ │ ├── test_exception_handler_applied_to_middleware_exception.py
│ │ ├── test_exception_handler_called_from_mounted_app.py
│ │ ├── test_exception_handler_called_if_no_middleware.py
│ │ ├── test_logging_middleware_with_multi_body_response.py
│ │ └── test_middleware_send_wrapper_called_on_error.py
│ ├── test_openapi
│ │ ├── __init__.py
│ │ └── test_spec_headers.py
│ ├── test_option_requests.py
│ ├── test_pydantic.py
│ ├── test_regular_handler_under_asgi_mount_path.py
│ ├── test_response_caching.py
│ ├── test_router_registration.py
│ ├── test_routing
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── test_asset_url_path.py
│ │ ├── test_path_mounting.py
│ │ ├── test_path_resolution.py
│ │ ├── test_route_indexing.py
│ │ ├── test_route_reverse.py
│ │ └── test_validations.py
│ └── test_starlette_responses.py
├── examples
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_application_hooks
│ │ ├── __init__.py
│ │ ├── test_application_after_exception_hook.py
│ │ ├── test_application_before_send.py
│ │ ├── test_lifespan_manager.py
│ │ └── test_on_app_init.py
│ ├── test_application_state
│ │ ├── __init__.py
│ │ ├── test_passing_initial_state.py
│ │ ├── test_using_application_state.py
│ │ ├── test_using_custom_state.py
│ │ └── test_using_immutable_state.py
│ ├── test_cache_control_headers.py
│ ├── test_contrib
│ │ ├── __init__.py
│ │ ├── prometheus
│ │ │ ├── __init__.py
│ │ │ ├── test_prometheus_exporter_example.py
│ │ │ └── test_prometheus_exporter_example_with_extra_config.py
│ │ ├── test_piccolo_orm.py
│ │ └── test_sqlalchemy
│ │ │ ├── __init__.py
│ │ │ ├── plugins
│ │ │ ├── __init__.py
│ │ │ ├── test_example_apps.py
│ │ │ └── test_tutorial_example_apps.py
│ │ │ └── test_sqlalchemy_examples.py
│ ├── test_data_transfer_objects
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── test_defining_dtos_on_layers.py
│ │ ├── test_factory
│ │ │ ├── __init__.py
│ │ │ ├── test_dto_data_problem_statement.py
│ │ │ ├── test_dto_data_usage.py
│ │ │ ├── test_leading_underscore_private.py
│ │ │ ├── test_leading_underscore_private_override.py
│ │ │ └── test_type_checking.py
│ │ └── test_overriding_implicit_return_dto.py
│ ├── test_datastructures
│ │ ├── __init__.py
│ │ └── test_secrets.py
│ ├── test_dependency_injection
│ │ ├── __init__.py
│ │ ├── test_dependency_default_value_no_dependency_fn.py
│ │ ├── test_dependency_default_value_with_dependency_fn.py
│ │ ├── test_dependency_skip_validation.py
│ │ ├── test_dependency_validation_error.py
│ │ └── tests_dependency_non_optional_not_provided.py
│ ├── test_dto
│ │ ├── __init__.py
│ │ ├── test_example_apps.py
│ │ └── test_tutorial.py
│ ├── test_encoding_decoding
│ │ ├── __init__.py
│ │ ├── test_custom_type_encoding_decoding.py
│ │ └── test_custom_type_pydantic.py
│ ├── test_exceptions.py
│ ├── test_hello_world.py
│ ├── test_lifecycle_hooks.py
│ ├── test_middleware
│ │ ├── __init__.py
│ │ ├── test_abstract_middleware.py
│ │ ├── test_call_order.py
│ │ ├── test_logging_middleware.py
│ │ ├── test_rate_limit_middleware.py
│ │ └── test_session_middleware.py
│ ├── test_openapi
│ │ ├── __init__.py
│ │ ├── test_openapi.py
│ │ └── test_plugins.py
│ ├── test_pagination
│ │ ├── __init__.py
│ │ ├── test_using_classic_pagination.py
│ │ ├── test_using_cursor_pagination.py
│ │ └── test_using_offset_pagination.py
│ ├── test_parameters
│ │ ├── __init__.py
│ │ ├── test_header_and_cookies_parameters.py
│ │ ├── test_layered_parameters.py
│ │ ├── test_path_parameters.py
│ │ └── test_query_parameters.py
│ ├── test_plugins
│ │ ├── __init__.py
│ │ ├── test_di_plugin.py
│ │ ├── test_example_apps.py
│ │ └── test_sqlalchemy_init_plugin.py
│ ├── test_request_data.py
│ ├── test_responses
│ │ ├── __init__.py
│ │ ├── test_background_tasks.py
│ │ ├── test_custom_responses.py
│ │ ├── test_json_suffix_responses.py
│ │ ├── test_response_cookies.py
│ │ ├── test_response_headers.py
│ │ ├── test_returning_responses.py
│ │ └── test_sse_responses.py
│ ├── test_routing.py
│ ├── test_security
│ │ ├── __init__.py
│ │ └── test_jwt
│ │ │ ├── __init__.py
│ │ │ ├── test_using_jwt_auth.py
│ │ │ ├── test_using_jwt_cookie_auth.py
│ │ │ ├── test_using_oauth2_password_bearer.py
│ │ │ └── test_verify_issuer_audience.py
│ ├── test_signature_namespace.py
│ ├── test_startup_and_shutdown.py
│ ├── test_static_files.py
│ ├── test_stores.py
│ ├── test_templating
│ │ ├── __init__.py
│ │ ├── test_engine_instance.py
│ │ ├── test_returning_templates.py
│ │ └── test_template_functions.py
│ ├── test_todo_app.py
│ ├── test_using_session_auth.py
│ └── test_websockets.py
├── helpers.py
├── models.py
└── unit
│ ├── __init__.py
│ ├── conftest.py
│ ├── piccolo_conf.py
│ ├── test_app.py
│ ├── test_asgi
│ ├── __init__.py
│ ├── test_asgi_router.py
│ └── test_routing_trie
│ │ ├── __init__.py
│ │ ├── test_mapping.py
│ │ └── test_traversal.py
│ ├── test_background_tasks.py
│ ├── test_channels
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_backends.py
│ ├── test_plugin.py
│ ├── test_subscriber.py
│ └── util.py
│ ├── test_cli
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_cli.py
│ ├── test_cli_plugin.py
│ ├── test_core_commands.py
│ ├── test_env_resolution.py
│ ├── test_schema_commands.py
│ ├── test_session_commands.py
│ └── test_ssl.py
│ ├── test_concurrency.py
│ ├── test_connection
│ ├── __init__.py
│ ├── test_base.py
│ ├── test_connection_caching.py
│ ├── test_request.py
│ └── test_websocket.py
│ ├── test_contrib
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_attrs.py
│ ├── test_htmx
│ │ ├── __init__.py
│ │ ├── test_htmx_deprecations.py
│ │ ├── test_htmx_request.py
│ │ └── test_htmx_response.py
│ ├── test_minijinja.py
│ ├── test_msgspec.py
│ ├── test_opentelemetry.py
│ ├── test_piccolo_orm
│ │ ├── __init__.py
│ │ ├── endpoints.py
│ │ ├── piccolo_app.py
│ │ ├── tables.py
│ │ └── test_piccolo_orm_dto.py
│ ├── test_prometheus.py
│ ├── test_pydantic.py
│ ├── test_repository.py
│ └── test_sqlalchemy.py
│ ├── test_controller.py
│ ├── test_data_extractors.py
│ ├── test_datastructures
│ ├── __init_.py
│ ├── test_cookie.py
│ ├── test_headers.py
│ ├── test_multi_dicts.py
│ ├── test_response_header.py
│ ├── test_secret_values.py
│ ├── test_state.py
│ ├── test_upload_file.py
│ └── test_url.py
│ ├── test_deprecations.py
│ ├── test_di.py
│ ├── test_dto
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_config.py
│ ├── test_factory
│ │ ├── __init__.py
│ │ ├── test_backends
│ │ │ ├── __init__.py
│ │ │ ├── conftest.py
│ │ │ ├── test_backends.py
│ │ │ ├── test_base_dto.py
│ │ │ └── test_utils.py
│ │ ├── test_base_dto.py
│ │ ├── test_dataclass_dto.py
│ │ ├── test_field.py
│ │ ├── test_integration.py
│ │ └── test_utils.py
│ ├── test_integration.py
│ └── test_interface.py
│ ├── test_events.py
│ ├── test_exceptions.py
│ ├── test_file_system.py
│ ├── test_guards.py
│ ├── test_handlers
│ ├── __init__.py
│ ├── test_asgi_handlers
│ │ ├── __init__.py
│ │ ├── test_handle_asgi.py
│ │ ├── test_handle_asgi_with_future_annotations.py
│ │ └── test_validations.py
│ ├── test_base_handlers
│ │ ├── __init__.py
│ │ ├── test_opt.py
│ │ ├── test_resolution.py
│ │ └── test_validations.py
│ ├── test_http_handlers
│ │ ├── __init__.py
│ │ ├── test_defaults.py
│ │ ├── test_delete.py
│ │ ├── test_deprecation.py
│ │ ├── test_head.py
│ │ ├── test_kwarg_handling.py
│ │ ├── test_media_type.py
│ │ ├── test_resolution.py
│ │ ├── test_signature_namespace.py
│ │ ├── test_sync.py
│ │ └── test_validations.py
│ └── test_websocket_handlers
│ │ ├── __init__.py
│ │ ├── test_handle_websocket.py
│ │ ├── test_handle_websocket_with_future_annotations.py
│ │ ├── test_kwarg_handling.py
│ │ ├── test_listeners.py
│ │ ├── test_stream.py
│ │ └── test_validations.py
│ ├── test_kwargs
│ ├── __init__.py
│ ├── flower.jpeg
│ ├── test_cleanup_group.py
│ ├── test_cookie_params.py
│ ├── test_defaults.py
│ ├── test_dependency_batches.py
│ ├── test_generator_dependencies.py
│ ├── test_header_params.py
│ ├── test_json_data.py
│ ├── test_layered_params.py
│ ├── test_msgpack_data.py
│ ├── test_multipart_data.py
│ ├── test_path_params.py
│ ├── test_query_params.py
│ ├── test_reserved_kwargs_injection.py
│ ├── test_url_encoded_data.py
│ └── test_validations.py
│ ├── test_logging
│ ├── __init__.py
│ ├── test_logging_config.py
│ └── test_structlog_config.py
│ ├── test_middleware
│ ├── __init__.py
│ ├── test_allowed_hosts_middleware.py
│ ├── test_base_authentication_middleware.py
│ ├── test_base_middleware.py
│ ├── test_compression_middleware.py
│ ├── test_cors_middleware.py
│ ├── test_csrf_middleware.py
│ ├── test_exception_handler_middleware.py
│ ├── test_logging_middleware.py
│ ├── test_middleware_handling.py
│ ├── test_rate_limit_middleware.py
│ └── test_session
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── test_client_side_backend.py
│ │ ├── test_integration.py
│ │ ├── test_middleware.py
│ │ └── test_server_side_backend.py
│ ├── test_openapi
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_config.py
│ ├── test_constrained_fields.py
│ ├── test_datastructures.py
│ ├── test_endpoints.py
│ ├── test_integration.py
│ ├── test_parameters.py
│ ├── test_path_item.py
│ ├── test_plugins.py
│ ├── test_render_plugins.py
│ ├── test_request_body.py
│ ├── test_responses.py
│ ├── test_schema.py
│ ├── test_security_schemes.py
│ ├── test_spec_generation.py
│ ├── test_tags.py
│ ├── test_typescript_converter
│ │ ├── __init__.py
│ │ ├── test_converter.py
│ │ ├── test_schema_parsing.py
│ │ └── test_typescript_types.py
│ └── utils.py
│ ├── test_pagination.py
│ ├── test_params.py
│ ├── test_parsers.py
│ ├── test_plugins
│ ├── __init__.py
│ ├── test_attrs
│ │ ├── __init__.py
│ │ ├── test_inject_attrs_class.py
│ │ ├── test_schema_plugin.py
│ │ ├── test_schema_spec_generation.py
│ │ └── test_signature.py
│ ├── test_base.py
│ ├── test_flash.py
│ ├── test_problem_details.py
│ ├── test_prometheus.py
│ ├── test_pydantic
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── models.py
│ │ ├── test_beanie_integration.py
│ │ ├── test_dto.py
│ │ ├── test_inject_pydantic.py
│ │ ├── test_integration.py
│ │ ├── test_openapi.py
│ │ ├── test_plugin_serialization.py
│ │ ├── test_pydantic_dto_factory.py
│ │ ├── test_schema_plugin.py
│ │ └── test_utils.py
│ └── test_sqlalchemy.py
│ ├── test_repository
│ ├── __init__.py
│ ├── models_bigint.py
│ ├── models_uuid.py
│ └── test_generic_mock_repository.py
│ ├── test_request_class_resolution.py
│ ├── test_response
│ ├── __init__.py
│ ├── test_base_response.py
│ ├── test_file_response.py
│ ├── test_redirect_response.py
│ ├── test_response_cookies.py
│ ├── test_response_headers.py
│ ├── test_response_to_asgi_response.py
│ ├── test_serialization.py
│ ├── test_sse.py
│ ├── test_streaming_response.py
│ ├── test_type_decoders.py
│ └── test_type_encoders.py
│ ├── test_response_class_resolution.py
│ ├── test_security
│ ├── __init__.py
│ ├── test_jwt
│ │ ├── __init__.py
│ │ ├── test_auth.py
│ │ ├── test_integration.py
│ │ └── test_token.py
│ ├── test_security.py
│ └── test_session_auth.py
│ ├── test_signature
│ ├── __init__.py
│ ├── test_parsing.py
│ └── test_validation.py
│ ├── test_static_files
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_create_static_router.py
│ ├── test_file_serving_resolution.py
│ ├── test_html_mode.py
│ └── test_static_files_validation.py
│ ├── test_stores.py
│ ├── test_template
│ ├── __init__.py
│ ├── test_built_in.py
│ ├── test_builtin_functions.py
│ ├── test_config.py
│ ├── test_context.py
│ ├── test_csrf_token.py
│ └── test_template.py
│ ├── test_testing
│ ├── __init__.py
│ ├── test_lifespan_handler.py
│ ├── test_request_factory.py
│ ├── test_sub_client
│ │ ├── __init__.py
│ │ ├── demo.py
│ │ └── test_subprocess_client.py
│ └── test_test_client.py
│ ├── test_types
│ ├── __init__.py
│ └── test_protocols.py
│ ├── test_typing.py
│ ├── test_utils
│ ├── __init__.py
│ ├── test_compat.py
│ ├── test_dataclass.py
│ ├── test_deprecation.py
│ ├── test_empty.py
│ ├── test_helpers.py
│ ├── test_module_loader.py
│ ├── test_path.py
│ ├── test_predicates.py
│ ├── test_scope.py
│ ├── test_sequence.py
│ ├── test_signature.py
│ ├── test_sync.py
│ ├── test_typing.py
│ └── test_version.py
│ └── test_websocket_class_resolution.py
├── tools
├── __init__.py
├── build_docs.py
├── prepare_release.py
├── pypi_readme.py
└── sphinx_ext
│ ├── __init__.py
│ ├── changelog.py
│ ├── missing_references.py
│ └── run_examples.py
├── typos.toml
└── uv.lock
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Code owner settings for `litestar`
2 | # @maintainers should be assigned to all reviews.
3 | # Most specific assignment takes precedence though, so if you add a more specific thing than the `*` glob, you must also add @maintainers
4 | # For more info about code owners see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-example
5 |
6 | # Global Assignment
7 | * @litestar-org/maintainers @litestar-org/members
8 |
9 | # Documentation
10 | docs/* @litestar-org/maintainers @JacobCoffee @provinzkraut
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/DOCS.yml:
--------------------------------------------------------------------------------
1 | name: "Documentation Update"
2 | description: Create an issue for documentation changes
3 | title: "Docs:
"
4 | labels:
5 | - "Documentation :books:"
6 | projects:
7 | - "litestar-org/16"
8 | body:
9 | - type: textarea
10 | id: summary
11 | attributes:
12 | label: "Summary"
13 | description: Provide a brief summary of your feature request
14 | placeholder: Describe in a few lines your feature request
15 | validations:
16 | required: true
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Litestar Documentation
4 | url: https://docs.litestar.dev/
5 | about: Official Litestar documentation - please check here before opening an issue.
6 | - name: Litestar Website
7 | url: https://litestar.dev/
8 | about: Main Litestar website - for details about Litestar's projects.
9 | - name: Discord
10 | url: https://discord.gg/litestar
11 | about: Join our Discord community to chat or get in touch with the maintainers.
12 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: CodeQL scheduled
2 | on:
3 | schedule:
4 | - cron: "0 4 * * *"
5 | jobs:
6 | codeql:
7 | runs-on: ubuntu-latest
8 | permissions:
9 | security-events: write
10 | steps:
11 | - name: Checkout repository
12 | uses: actions/checkout@v4
13 | with:
14 | ref: "main"
15 | - name: Initialize CodeQL With Dependencies
16 | uses: github/codeql-action/init@v3
17 | - name: Perform CodeQL Analysis
18 | uses: github/codeql-action/analyze@v3
19 |
--------------------------------------------------------------------------------
/.github/workflows/pr-title.yml:
--------------------------------------------------------------------------------
1 | name: "Lint PR Title"
2 |
3 | on:
4 | pull_request_target:
5 | types:
6 | - opened
7 | - edited
8 | - synchronize
9 |
10 | permissions:
11 | pull-requests: read
12 |
13 | jobs:
14 | main:
15 | name: Validate PR title
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: amannn/action-semantic-pull-request@v5
19 | env:
20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | status:
3 | project:
4 | default:
5 | target: auto
6 | threshold: 0.1%
7 | patch:
8 | default:
9 | target: auto
10 | comment:
11 | require_changes: true
12 |
--------------------------------------------------------------------------------
/docs/_static/versions.json:
--------------------------------------------------------------------------------
1 | { "versions": ["1", "2", "main", "3-dev"], "latest": "2" }
2 |
--------------------------------------------------------------------------------
/docs/contribution-guide.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | .. include:: ../CONTRIBUTING.rst
4 |
--------------------------------------------------------------------------------
/docs/examples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/__init__.py
--------------------------------------------------------------------------------
/docs/examples/application_hooks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/application_hooks/__init__.py
--------------------------------------------------------------------------------
/docs/examples/application_state/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/application_state/__init__.py
--------------------------------------------------------------------------------
/docs/examples/application_state/passing_initial_state.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.datastructures import State
5 |
6 |
7 | @get("/", sync_to_thread=False)
8 | def handler(state: State) -> Dict[str, Any]:
9 | return state.dict()
10 |
11 |
12 | app = Litestar(route_handlers=[handler], state=State({"count": 100}))
13 |
--------------------------------------------------------------------------------
/docs/examples/application_state/using_custom_state.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.datastructures import State
5 |
6 |
7 | class MyState(State):
8 | count: int = 0
9 |
10 | def increment(self) -> None:
11 | self.count += 1
12 |
13 |
14 | @get("/", sync_to_thread=False)
15 | def handler(state: MyState) -> Dict[str, Any]:
16 | state.increment()
17 | return state.dict()
18 |
19 |
20 | app = Litestar(route_handlers=[handler])
21 |
--------------------------------------------------------------------------------
/docs/examples/application_state/using_immutable_state.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.datastructures import ImmutableState
5 |
6 |
7 | @get("/", sync_to_thread=False)
8 | def handler(state: ImmutableState) -> Dict[str, Any]:
9 | setattr(state, "count", 1) # raises AttributeError
10 | return state.dict()
11 |
12 |
13 | app = Litestar(route_handlers=[handler])
14 |
--------------------------------------------------------------------------------
/docs/examples/caching/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/caching/__init__.py
--------------------------------------------------------------------------------
/docs/examples/caching/cache_response_filter.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.config.response_cache import ResponseCacheConfig
3 | from litestar.types import HTTPScope
4 |
5 |
6 | def custom_cache_response_filter(_: HTTPScope, status_code: int) -> bool:
7 | # Cache only 2xx responses
8 | return 200 <= status_code < 300
9 |
10 |
11 | response_cache_config = ResponseCacheConfig(cache_response_filter=custom_cache_response_filter)
12 |
13 | # Create the app with a custom cache response filter
14 | app = Litestar(
15 | response_cache_config=response_cache_config,
16 | )
17 |
--------------------------------------------------------------------------------
/docs/examples/caching/key_builder.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, Request
2 | from litestar.config.response_cache import ResponseCacheConfig
3 |
4 |
5 | def key_builder(request: Request) -> str:
6 | return request.url.path + request.headers.get("my-header", "")
7 |
8 |
9 | app = Litestar([], response_cache_config=ResponseCacheConfig(key_builder=key_builder))
10 |
--------------------------------------------------------------------------------
/docs/examples/caching/key_builder_for_route_handler.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, Request, get
2 |
3 |
4 | def key_builder(request: Request) -> str:
5 | return request.url.path + request.headers.get("my-header", "")
6 |
7 |
8 | @get("/cached-path", cache=True, cache_key_builder=key_builder)
9 | async def cached_handler() -> str:
10 | return "cached"
11 |
12 |
13 | app = Litestar([cached_handler])
14 |
--------------------------------------------------------------------------------
/docs/examples/caching/redis_store.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from litestar import Litestar, get
4 | from litestar.config.response_cache import ResponseCacheConfig
5 | from litestar.stores.redis import RedisStore
6 |
7 |
8 | @get(cache=10)
9 | async def something() -> str:
10 | await asyncio.sleep(1)
11 | return "something"
12 |
13 |
14 | redis_store = RedisStore.with_client(url="redis://localhost/", port=6379, db=0)
15 | cache_config = ResponseCacheConfig(store="redis_backed_store")
16 | app = Litestar(
17 | [something],
18 | stores={"redis_backed_store": redis_store},
19 | response_cache_config=cache_config,
20 | )
21 |
--------------------------------------------------------------------------------
/docs/examples/channels/create_route_handlers.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.channels import ChannelsPlugin
3 | from litestar.channels.backends.memory import MemoryChannelsBackend
4 |
5 | channels_plugin = ChannelsPlugin(
6 | backend=MemoryChannelsBackend(),
7 | channels=["foo", "bar"],
8 | create_ws_route_handlers=True,
9 | )
10 |
11 | app = Litestar(plugins=[channels_plugin])
12 |
--------------------------------------------------------------------------------
/docs/examples/channels/create_route_handlers_send_history.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.channels import ChannelsPlugin
3 | from litestar.channels.backends.memory import MemoryChannelsBackend
4 |
5 | channels_plugin = ChannelsPlugin(
6 | backend=MemoryChannelsBackend(history=10), # set the amount of messages per channel
7 | # to keep in the backend
8 | channels=["foo", "bar"],
9 | create_ws_route_handlers=True,
10 | ws_handler_send_history=10, # send 10 entries of the history by default
11 | )
12 |
13 | app = Litestar(plugins=[channels_plugin])
14 |
--------------------------------------------------------------------------------
/docs/examples/channels/put_history.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, WebSocket, websocket
2 | from litestar.channels import ChannelsPlugin
3 | from litestar.channels.backends.memory import MemoryChannelsBackend
4 |
5 |
6 | @websocket("/ws")
7 | async def handler(socket: WebSocket, channels: ChannelsPlugin) -> None:
8 | await socket.accept()
9 |
10 | async with channels.start_subscription(["some_channel"]) as subscriber:
11 | await channels.put_subscriber_history(subscriber, ["some_channel"], limit=10)
12 |
13 |
14 | app = Litestar(
15 | [handler],
16 | plugins=[ChannelsPlugin(backend=MemoryChannelsBackend(history=20))],
17 | )
18 |
--------------------------------------------------------------------------------
/docs/examples/contrib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/contrib/__init__.py
--------------------------------------------------------------------------------
/docs/examples/contrib/piccolo/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/contrib/piccolo/__init__.py
--------------------------------------------------------------------------------
/docs/examples/contrib/piccolo/piccolo_conf.py:
--------------------------------------------------------------------------------
1 | from piccolo.engine.sqlite import SQLiteEngine
2 |
3 | DB = SQLiteEngine()
4 |
--------------------------------------------------------------------------------
/docs/examples/contrib/sqlalchemy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/contrib/sqlalchemy/__init__.py
--------------------------------------------------------------------------------
/docs/examples/contrib/sqlalchemy/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/contrib/sqlalchemy/plugins/__init__.py
--------------------------------------------------------------------------------
/docs/examples/contrib/sqlalchemy/plugins/sqlalchemy_async_before_send_handler.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar import Litestar
4 | from litestar.plugins.sqlalchemy import (
5 | SQLAlchemyAsyncConfig,
6 | SQLAlchemyInitPlugin,
7 | async_autocommit_before_send_handler,
8 | )
9 |
10 | config = SQLAlchemyAsyncConfig(
11 | connection_string="sqlite+aiosqlite:///:memory:", before_send_handler=async_autocommit_before_send_handler
12 | )
13 | plugin = SQLAlchemyInitPlugin(config=config)
14 |
15 | app = Litestar(route_handlers=[], plugins=[plugin])
16 |
--------------------------------------------------------------------------------
/docs/examples/contrib/sqlalchemy/plugins/sqlalchemy_sync_before_send_handler.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar import Litestar
4 | from litestar.plugins.sqlalchemy import SQLAlchemyInitPlugin, SQLAlchemySyncConfig, sync_autocommit_before_send_handler
5 |
6 | config = SQLAlchemySyncConfig(
7 | connection_string="sqlite:///:memory:",
8 | before_send_handler=sync_autocommit_before_send_handler,
9 | )
10 | plugin = SQLAlchemyInitPlugin(config=config)
11 |
12 | app = Litestar(route_handlers=[], plugins=[plugin])
13 |
--------------------------------------------------------------------------------
/docs/examples/contrib/sqlalchemy/plugins/tutorial/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/contrib/sqlalchemy/plugins/tutorial/__init__.py
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/data_transfer_objects/__init__.py
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/factory/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/data_transfer_objects/factory/__init__.py
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/factory/leading_underscore_private.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 | from litestar import Litestar, post
4 | from litestar.dto import DataclassDTO
5 |
6 |
7 | @dataclass
8 | class Foo:
9 | this_will: str
10 | _this_will: str = "Mars"
11 |
12 |
13 | @post("/", dto=DataclassDTO[Foo], sync_to_thread=False)
14 | def handler(data: Foo) -> Foo:
15 | return data
16 |
17 |
18 | app = Litestar(route_handlers=[handler])
19 |
20 | # run: / -H "Content-Type: application/json" -d '{"bar":"stay","_baz":"go_away!"}'
21 |
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/factory/tutorial/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/data_transfer_objects/factory/tutorial/__init__.py
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/models.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from dataclasses import dataclass
4 | from uuid import UUID
5 |
6 | from litestar.dto import DataclassDTO
7 |
8 |
9 | @dataclass
10 | class User:
11 | id: UUID
12 | name: str
13 |
14 |
15 | UserDTO = DataclassDTO[User]
16 | UserReturnDTO = DataclassDTO[User]
17 |
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/overriding_implicit_return_dto.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass, field
2 | from uuid import UUID, uuid4
3 |
4 | from litestar import Litestar, post
5 | from litestar.dto import DataclassDTO
6 |
7 |
8 | @dataclass
9 | class User:
10 | name: str
11 | email: str
12 | age: int
13 | id: UUID = field(default_factory=uuid4)
14 |
15 |
16 | UserDTO = DataclassDTO[User]
17 |
18 |
19 | @post(dto=UserDTO, return_dto=None, sync_to_thread=False)
20 | def create_user(data: User) -> bytes:
21 | return data.name.encode(encoding="utf-8")
22 |
23 |
24 | app = Litestar([create_user])
25 |
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/the_dto_parameter.py:
--------------------------------------------------------------------------------
1 | from litestar import post
2 |
3 | from .models import User, UserDTO
4 |
5 |
6 | @post(dto=UserDTO)
7 | def create_user(data: User) -> User:
8 | return data
9 |
--------------------------------------------------------------------------------
/docs/examples/data_transfer_objects/the_return_dto_parameter.py:
--------------------------------------------------------------------------------
1 | from litestar import post
2 |
3 | from .models import User, UserDTO, UserReturnDTO
4 |
5 |
6 | @post(dto=UserDTO, return_dto=UserReturnDTO)
7 | def create_user(data: User) -> User:
8 | return data
9 |
--------------------------------------------------------------------------------
/docs/examples/datastructures/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/datastructures/__init__.py
--------------------------------------------------------------------------------
/docs/examples/datastructures/headers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/datastructures/headers/__init__.py
--------------------------------------------------------------------------------
/docs/examples/datastructures/headers/etag_parsing.py:
--------------------------------------------------------------------------------
1 | from litestar.datastructures import ETag
2 |
3 | assert ETag.from_header('"foo"') == ETag(value="foo")
4 | assert ETag.from_header('W/"foo"') == ETag(value="foo", weak=True)
5 |
--------------------------------------------------------------------------------
/docs/examples/datastructures/secrets/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/datastructures/secrets/__init__.py
--------------------------------------------------------------------------------
/docs/examples/datastructures/secrets/secret_body.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 | from litestar import post
4 | from litestar.datastructures.secret_values import SecretString
5 |
6 |
7 | @dataclass
8 | class Sensitive:
9 | value: SecretString
10 |
11 |
12 | @post(sync_to_thread=False)
13 | def post_handler(data: Sensitive) -> Sensitive:
14 | return data
15 |
--------------------------------------------------------------------------------
/docs/examples/dependency_injection/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/dependency_injection/__init__.py
--------------------------------------------------------------------------------
/docs/examples/dependency_injection/dependency_validation_error.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.di import Provide
5 |
6 |
7 | async def provide_str() -> str:
8 | """Returns a string."""
9 | return "whoops"
10 |
11 |
12 | @get("/", dependencies={"injected": Provide(provide_str)}, sync_to_thread=False)
13 | def hello_world(injected: int) -> Dict[str, Any]:
14 | """Handler expects an `int`, but we've provided a `str`."""
15 | return {"hello": injected}
16 |
17 |
18 | app = Litestar(route_handlers=[hello_world])
19 |
--------------------------------------------------------------------------------
/docs/examples/dependency_injection/dependency_with_default.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from litestar import Litestar, get
4 |
5 |
6 | @get("/", sync_to_thread=False)
7 | def hello_world(optional_dependency: int = 3) -> Dict[str, Any]:
8 | """Notice we haven't provided the dependency to the route.
9 |
10 | This is OK, because of the default value, but the parameter shows in the docs.
11 | """
12 | return {"hello": optional_dependency}
13 |
14 |
15 | app = Litestar(route_handlers=[hello_world])
16 |
--------------------------------------------------------------------------------
/docs/examples/deployment/nginx-unit/install-macos.sh:
--------------------------------------------------------------------------------
1 | brew install unit-python311
2 | brew install nginx/unit/unit-python3
3 |
--------------------------------------------------------------------------------
/docs/examples/deployment/nginx-unit/unit.json:
--------------------------------------------------------------------------------
1 | {
2 | "listeners": {
3 | "*:8080": {
4 | "pass": "applications/litestar"
5 | }
6 | },
7 |
8 | "applications": {
9 | "litestar": {
10 | "type": "python 3.11",
11 | "home": "/Users/user/project/litestar/.venv/",
12 | "path": "/Users/user/project/litestar/src/app",
13 | "module": "run",
14 | "callable": "app",
15 | "stderr": "/Users/user/project/litestar/error.log",
16 | "user": "user",
17 | "processes": 1
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/docs/examples/encoding_decoding/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/encoding_decoding/__init__.py
--------------------------------------------------------------------------------
/docs/examples/exceptions/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/exceptions/__init__.py
--------------------------------------------------------------------------------
/docs/examples/exceptions/implicit_media_type.py:
--------------------------------------------------------------------------------
1 | from litestar import get
2 |
3 |
4 | @get(sync_to_thread=False)
5 | def handler(q: int) -> str:
6 | raise ValueError
7 |
--------------------------------------------------------------------------------
/docs/examples/hello_world.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 |
5 |
6 | @get("/")
7 | async def hello_world() -> Dict[str, str]:
8 | """Handler function that returns a greeting dictionary."""
9 | return {"hello": "world"}
10 |
11 |
12 | app = Litestar(route_handlers=[hello_world])
13 |
14 | # run: /
15 |
--------------------------------------------------------------------------------
/docs/examples/lifecycle_hooks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/lifecycle_hooks/__init__.py
--------------------------------------------------------------------------------
/docs/examples/lifecycle_hooks/after_response.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 | from typing import Dict
3 |
4 | from litestar import Litestar, Request, get
5 |
6 | COUNTER: Dict[str, int] = defaultdict(int)
7 |
8 |
9 | async def after_response(request: Request) -> None:
10 | COUNTER[request.url.path] += 1
11 |
12 |
13 | @get("/hello")
14 | async def hello() -> Dict[str, int]:
15 | return COUNTER
16 |
17 |
18 | app = Litestar(route_handlers=[hello], after_response=after_response)
19 |
20 |
21 | # run: /hello
22 | # run: /hello
23 |
--------------------------------------------------------------------------------
/docs/examples/middleware/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/middleware/__init__.py
--------------------------------------------------------------------------------
/docs/examples/middleware/abstract_middleware_migration_new.py:
--------------------------------------------------------------------------------
1 | import anyio
2 |
3 | from litestar import Litestar
4 | from litestar.middleware import ASGIMiddleware
5 | from litestar.types import ASGIApp, Receive, Scope, Send
6 |
7 |
8 | class TimeoutMiddleware(ASGIMiddleware):
9 | def __init__(self, timeout: float):
10 | self.timeout = timeout
11 |
12 | async def handle(self, scope: Scope, receive: Receive, send: Send, next_app: ASGIApp) -> None:
13 | with anyio.move_on_after(self.timeout):
14 | await next_app(scope, receive, send)
15 |
16 |
17 | app = Litestar(middleware=[TimeoutMiddleware(timeout=5)])
18 |
--------------------------------------------------------------------------------
/docs/examples/middleware/logging_middleware.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.logging.config import LoggingConfig
5 | from litestar.middleware.logging import LoggingMiddlewareConfig
6 |
7 | logging_middleware_config = LoggingMiddlewareConfig()
8 |
9 |
10 | @get("/", sync_to_thread=False)
11 | def my_handler() -> Dict[str, str]:
12 | return {"hello": "world"}
13 |
14 |
15 | app = Litestar(
16 | route_handlers=[my_handler],
17 | logging_config=LoggingConfig(),
18 | middleware=[logging_middleware_config.middleware],
19 | )
20 |
--------------------------------------------------------------------------------
/docs/examples/middleware/middleware_protocol_migration_new.py:
--------------------------------------------------------------------------------
1 | from litestar.middleware import ASGIMiddleware
2 | from litestar.types import ASGIApp, Receive, Scope, Send
3 |
4 |
5 | class MyMiddleware(ASGIMiddleware):
6 | async def handle(self, scope: Scope, receive: Receive, send: Send, next_app: ASGIApp) -> None:
7 | # do stuff
8 | await next_app(scope, receive, send)
9 |
--------------------------------------------------------------------------------
/docs/examples/middleware/middleware_protocol_migration_old.py:
--------------------------------------------------------------------------------
1 | from litestar.middleware import MiddlewareProtocol
2 | from litestar.types import ASGIApp, Receive, Scope, Send
3 |
4 |
5 | class MyMiddleware(MiddlewareProtocol):
6 | def __init__(self, app: ASGIApp) -> None:
7 | self.app = app
8 |
9 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
10 | # do stuff
11 | await self.app(scope, receive, send)
12 |
--------------------------------------------------------------------------------
/docs/examples/middleware/rate_limit.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, MediaType, get
2 | from litestar.middleware.rate_limit import RateLimitConfig
3 |
4 | rate_limit_config = RateLimitConfig(rate_limit=("minute", 1), exclude=["/schema"])
5 |
6 |
7 | @get("/", media_type=MediaType.TEXT, sync_to_thread=False)
8 | def handler() -> str:
9 | """Handler which should not be accessed more than once per minute."""
10 | return "ok"
11 |
12 |
13 | app = Litestar(route_handlers=[handler], middleware=[rate_limit_config.middleware])
14 |
--------------------------------------------------------------------------------
/docs/examples/middleware/session/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/middleware/session/__init__.py
--------------------------------------------------------------------------------
/docs/examples/middleware/session/cookie_backend.py:
--------------------------------------------------------------------------------
1 | from os import urandom
2 |
3 | from litestar import Litestar
4 | from litestar.middleware.session.client_side import CookieBackendConfig
5 |
6 | session_config = CookieBackendConfig(secret=urandom(16)) # type: ignore
7 |
8 | app = Litestar(middleware=[session_config.middleware])
9 |
--------------------------------------------------------------------------------
/docs/examples/middleware/session/file_store.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.middleware.session.server_side import ServerSideSessionConfig
5 | from litestar.stores.file import FileStore
6 |
7 | app = Litestar(
8 | middleware=[ServerSideSessionConfig().middleware],
9 | stores={"sessions": FileStore(path=Path("session_data"))},
10 | )
11 |
--------------------------------------------------------------------------------
/docs/examples/openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/openapi/__init__.py
--------------------------------------------------------------------------------
/docs/examples/openapi/customize_path.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 |
6 |
7 | @get("/")
8 | def hello_world() -> Dict[str, str]:
9 | return {"message": "Hello World"}
10 |
11 |
12 | app = Litestar(
13 | route_handlers=[hello_world],
14 | openapi_config=OpenAPIConfig(
15 | title="My API",
16 | description="This is the description of my API",
17 | version="0.1.0",
18 | path="/docs",
19 | ),
20 | )
21 |
--------------------------------------------------------------------------------
/docs/examples/openapi/customize_pydantic_model_name.py:
--------------------------------------------------------------------------------
1 | from uuid import UUID, uuid4
2 |
3 | from pydantic import BaseModel
4 |
5 | from litestar import Litestar, get
6 |
7 |
8 | class IdModel(BaseModel):
9 | __schema_name__ = "IdContainer"
10 |
11 | id: UUID
12 |
13 |
14 | @get("/id", sync_to_thread=False)
15 | def retrieve_id_handler() -> IdModel:
16 | """
17 |
18 | Returns: An IdModel
19 |
20 | """
21 | return IdModel(id=uuid4())
22 |
23 |
24 | app = Litestar(route_handlers=[retrieve_id_handler])
25 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/openapi/plugins/__init__.py
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/rapidoc_config.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import RapidocRenderPlugin
2 |
3 | rapidoc_plugin = RapidocRenderPlugin(version="9.3.4", path="/rapidoc")
4 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/rapidoc_simple.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 | from litestar.openapi.plugins import RapidocRenderPlugin
6 |
7 |
8 | @get("/", sync_to_thread=False)
9 | def hello_world() -> Dict[str, str]:
10 | return {"message": "Hello World"}
11 |
12 |
13 | app = Litestar(
14 | route_handlers=[hello_world],
15 | openapi_config=OpenAPIConfig(
16 | title="Litestar Example",
17 | description="Example of litestar",
18 | version="0.0.1",
19 | render_plugins=[RapidocRenderPlugin()],
20 | ),
21 | )
22 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/redoc_config.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import RedocRenderPlugin
2 |
3 | redoc_plugin = RedocRenderPlugin(version="next", google_fonts=True, path="/redoc")
4 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/redoc_simple.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 | from litestar.openapi.plugins import RedocRenderPlugin
6 |
7 |
8 | @get("/", sync_to_thread=False)
9 | def hello_world() -> Dict[str, str]:
10 | return {"message": "Hello World"}
11 |
12 |
13 | app = Litestar(
14 | route_handlers=[hello_world],
15 | openapi_config=OpenAPIConfig(
16 | title="Litestar Example",
17 | description="Example of litestar",
18 | version="0.0.1",
19 | render_plugins=[RedocRenderPlugin()],
20 | ),
21 | )
22 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/scalar_config.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import ScalarRenderPlugin
2 |
3 | scalar_plugin = ScalarRenderPlugin(version="1.19.5", path="/scalar")
4 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/scalar_customized.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import ScalarRenderPlugin
2 |
3 | scalar_plugin = ScalarRenderPlugin(
4 | js_url="https://example.com/my-custom-scalar.js",
5 | css_url="https://example.com/my-custom-scalar.css",
6 | path="/scalar",
7 | )
8 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/stoplight_config.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import StoplightRenderPlugin
2 |
3 | stoplight_plugin = StoplightRenderPlugin(version="7.7.18", path="/elements")
4 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/stoplight_simple.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 | from litestar.openapi.plugins import StoplightRenderPlugin
6 |
7 |
8 | @get("/", sync_to_thread=False)
9 | def hello_world() -> Dict[str, str]:
10 | return {"message": "Hello World"}
11 |
12 |
13 | app = Litestar(
14 | route_handlers=[hello_world],
15 | openapi_config=OpenAPIConfig(
16 | title="Litestar Example",
17 | description="Example of litestar",
18 | version="0.0.1",
19 | render_plugins=[StoplightRenderPlugin()],
20 | ),
21 | )
22 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/swagger_ui_config.py:
--------------------------------------------------------------------------------
1 | from litestar.openapi.plugins import SwaggerRenderPlugin
2 |
3 | swagger_plugin = SwaggerRenderPlugin(version="5.18.2", path="/swagger")
4 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/swagger_ui_simple.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 | from litestar.openapi.plugins import SwaggerRenderPlugin
6 |
7 |
8 | @get("/", sync_to_thread=False)
9 | def hello_world() -> Dict[str, str]:
10 | return {"message": "Hello World"}
11 |
12 |
13 | app = Litestar(
14 | route_handlers=[hello_world],
15 | openapi_config=OpenAPIConfig(
16 | title="Litestar Example",
17 | description="Example of litestar",
18 | version="0.0.1",
19 | render_plugins=[SwaggerRenderPlugin()],
20 | ),
21 | )
22 |
--------------------------------------------------------------------------------
/docs/examples/openapi/plugins/yaml_simple.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 | from litestar.openapi.config import OpenAPIConfig
5 | from litestar.openapi.plugins import YamlRenderPlugin
6 |
7 |
8 | @get("/", sync_to_thread=False)
9 | def hello_world() -> Dict[str, str]:
10 | return {"message": "Hello World"}
11 |
12 |
13 | app = Litestar(
14 | route_handlers=[hello_world],
15 | openapi_config=OpenAPIConfig(
16 | title="Litestar Example",
17 | description="Example of litestar",
18 | version="0.0.1",
19 | render_plugins=[YamlRenderPlugin()],
20 | ),
21 | )
22 |
--------------------------------------------------------------------------------
/docs/examples/pagination/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/pagination/__init__.py
--------------------------------------------------------------------------------
/docs/examples/parameters/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/parameters/__init__.py
--------------------------------------------------------------------------------
/docs/examples/parameters/path_parameters_1.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseModel
2 |
3 | from litestar import Litestar, get
4 |
5 | USER_DB = {1: {"id": 1, "name": "John Doe"}}
6 |
7 |
8 | class User(BaseModel):
9 | id: int
10 | name: str
11 |
12 |
13 | @get("/user/{user_id:int}", sync_to_thread=False)
14 | def get_user(user_id: int) -> User:
15 | return User.model_validate(USER_DB[user_id])
16 |
17 |
18 | app = Litestar(route_handlers=[get_user])
19 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 |
5 |
6 | @get("/", sync_to_thread=False)
7 | def index(param: str) -> Dict[str, str]:
8 | return {"param": param}
9 |
10 |
11 | app = Litestar(route_handlers=[index])
12 |
13 | # run: /?param=foo
14 | # run: /?param=bar
15 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params_constraints.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from typing_extensions import Annotated
4 |
5 | from litestar import Litestar, get
6 | from litestar.params import Parameter
7 |
8 |
9 | @get("/", sync_to_thread=False)
10 | def index(param: Annotated[int, Parameter(gt=5)]) -> Dict[str, int]:
11 | return {"param": param}
12 |
13 |
14 | app = Litestar(route_handlers=[index])
15 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params_default.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, get
4 |
5 |
6 | @get("/", sync_to_thread=False)
7 | def index(param: str = "hello") -> Dict[str, str]:
8 | return {"param": param}
9 |
10 |
11 | app = Litestar(route_handlers=[index])
12 |
13 |
14 | # run: /
15 | # run: /?param=john
16 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params_optional.py:
--------------------------------------------------------------------------------
1 | from typing import Dict, Optional
2 |
3 | from litestar import Litestar, get
4 |
5 |
6 | @get("/", sync_to_thread=False)
7 | def index(param: Optional[str] = None) -> Dict[str, Optional[str]]:
8 | return {"param": param}
9 |
10 |
11 | app = Litestar(route_handlers=[index])
12 |
13 |
14 | # run: /
15 | # run: /?param=goodbye
16 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params_remap.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from typing_extensions import Annotated
4 |
5 | from litestar import Litestar, get
6 | from litestar.params import Parameter
7 |
8 |
9 | @get("/", sync_to_thread=False)
10 | def index(snake_case: Annotated[str, Parameter(query="camelCase")]) -> Dict[str, str]:
11 | return {"param": snake_case}
12 |
13 |
14 | app = Litestar(route_handlers=[index])
15 |
16 | # run: /?camelCase=foo
17 |
--------------------------------------------------------------------------------
/docs/examples/parameters/query_params_types.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime, timedelta
2 | from typing import Any, Dict, List
3 |
4 | from litestar import Litestar, get
5 |
6 |
7 | @get("/", sync_to_thread=False)
8 | def index(date: datetime, number: int, floating_number: float, strings: List[str]) -> Dict[str, Any]:
9 | return {
10 | "datetime": date + timedelta(days=1),
11 | "int": number,
12 | "float": floating_number,
13 | "list": strings,
14 | }
15 |
16 |
17 | app = Litestar(route_handlers=[index])
18 |
19 |
20 | # run: /?date=2022-11-28T13:22:06.916540&floating_number=0.1&number=42&strings=1&strings=2
21 |
--------------------------------------------------------------------------------
/docs/examples/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/plugins/__init__.py
--------------------------------------------------------------------------------
/docs/examples/plugins/flash_messages/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/plugins/flash_messages/__init__.py
--------------------------------------------------------------------------------
/docs/examples/plugins/flash_messages/jinja.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.contrib.jinja import JinjaTemplateEngine
3 | from litestar.middleware.session.server_side import ServerSideSessionConfig
4 | from litestar.plugins.flash import FlashConfig, FlashPlugin
5 | from litestar.template.config import TemplateConfig
6 |
7 | template_config = TemplateConfig(engine=JinjaTemplateEngine, directory="templates")
8 | flash_plugin = FlashPlugin(config=FlashConfig(template_config=template_config))
9 |
10 | app = Litestar(
11 | plugins=[flash_plugin],
12 | middleware=[ServerSideSessionConfig().middleware],
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/plugins/flash_messages/mako.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.contrib.mako import MakoTemplateEngine
3 | from litestar.middleware.session.server_side import ServerSideSessionConfig
4 | from litestar.plugins.flash import FlashConfig, FlashPlugin
5 | from litestar.template.config import TemplateConfig
6 |
7 | template_config = TemplateConfig(engine=MakoTemplateEngine, directory="templates")
8 | flash_plugin = FlashPlugin(config=FlashConfig(template_config=template_config))
9 |
10 | app = Litestar(
11 | plugins=[flash_plugin],
12 | middleware=[ServerSideSessionConfig().middleware],
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/plugins/flash_messages/minijinja.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.contrib.minijinja import MiniJinjaTemplateEngine
3 | from litestar.middleware.session.server_side import ServerSideSessionConfig
4 | from litestar.plugins.flash import FlashConfig, FlashPlugin
5 | from litestar.template.config import TemplateConfig
6 |
7 | template_config = TemplateConfig(engine=MiniJinjaTemplateEngine, directory="templates")
8 | flash_plugin = FlashPlugin(config=FlashConfig(template_config=template_config))
9 |
10 | app = Litestar(
11 | plugins=[flash_plugin],
12 | middleware=[ServerSideSessionConfig().middleware],
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/plugins/prometheus/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/plugins/prometheus/__init__.py
--------------------------------------------------------------------------------
/docs/examples/plugins/sqlalchemy/configure.py:
--------------------------------------------------------------------------------
1 | from litestar.plugins.sqlalchemy import SQLAlchemyAsyncConfig, SQLAlchemyPlugin
2 |
3 | sqlalchemy_config = SQLAlchemyAsyncConfig(connection_string="sqlite+aiosqlite:///test.sqlite")
4 | plugin = SQLAlchemyPlugin(config=sqlalchemy_config)
5 |
--------------------------------------------------------------------------------
/docs/examples/plugins/sqlalchemy/modelling.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy.orm import Mapped
2 |
3 | from litestar.plugins.sqlalchemy import base
4 |
5 |
6 | class TodoItem(base.UUIDBase):
7 | title: Mapped[str]
8 | done: Mapped[bool]
9 |
--------------------------------------------------------------------------------
/docs/examples/plugins/sqlalchemy_init_plugin/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/plugins/sqlalchemy_init_plugin/__init__.py
--------------------------------------------------------------------------------
/docs/examples/request_data/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/request_data/__init__.py
--------------------------------------------------------------------------------
/docs/examples/request_data/msgpack_request.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | from typing_extensions import Annotated
4 |
5 | from litestar import Litestar, post
6 | from litestar.enums import RequestEncodingType
7 | from litestar.params import Body
8 |
9 |
10 | @post(path="/", sync_to_thread=False)
11 | def msgpack_handler(
12 | data: Annotated[Dict[str, Any], Body(media_type=RequestEncodingType.MESSAGEPACK)],
13 | ) -> Dict[str, Any]:
14 | # This will try to parse the request body as `MessagePack` regardless of the
15 | # `Content-Type`
16 | return data
17 |
18 |
19 | app = Litestar(route_handlers=[msgpack_handler])
20 |
--------------------------------------------------------------------------------
/docs/examples/request_data/request_data_1.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, post
4 |
5 |
6 | @post(path="/")
7 | async def index(data: Dict[str, str]) -> Dict[str, str]:
8 | return data
9 |
10 |
11 | app = Litestar(route_handlers=[index])
12 |
--------------------------------------------------------------------------------
/docs/examples/request_data/request_data_2.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 | from litestar import Litestar, post
4 |
5 |
6 | @dataclass
7 | class User:
8 | id: int
9 | name: str
10 |
11 |
12 | @post(path="/")
13 | async def index(data: User) -> User:
14 | return data
15 |
16 |
17 | app = Litestar(route_handlers=[index])
18 |
--------------------------------------------------------------------------------
/docs/examples/request_data/request_data_3.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 | from typing_extensions import Annotated
4 |
5 | from litestar import Litestar, post
6 | from litestar.params import Body
7 |
8 |
9 | @dataclass
10 | class User:
11 | id: int
12 | name: str
13 |
14 |
15 | @post(path="/")
16 | async def create_user(
17 | data: Annotated[User, Body(title="Create User", description="Create a new user.")],
18 | ) -> User:
19 | return data
20 |
21 |
22 | app = Litestar(route_handlers=[create_user])
23 |
--------------------------------------------------------------------------------
/docs/examples/request_data/request_data_4.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 | from typing_extensions import Annotated
4 |
5 | from litestar import Litestar, post
6 | from litestar.enums import RequestEncodingType
7 | from litestar.params import Body
8 |
9 |
10 | @dataclass
11 | class User:
12 | id: int
13 | name: str
14 |
15 |
16 | @post(path="/")
17 | async def create_user(
18 | data: Annotated[User, Body(media_type=RequestEncodingType.URL_ENCODED)],
19 | ) -> User:
20 | return data
21 |
22 |
23 | app = Litestar(route_handlers=[create_user])
24 |
--------------------------------------------------------------------------------
/docs/examples/request_data/request_data_6.py:
--------------------------------------------------------------------------------
1 | from typing_extensions import Annotated
2 |
3 | from litestar import Litestar, MediaType, post
4 | from litestar.datastructures import UploadFile
5 | from litestar.enums import RequestEncodingType
6 | from litestar.params import Body
7 |
8 |
9 | @post(path="/", media_type=MediaType.TEXT)
10 | async def handle_file_upload(
11 | data: Annotated[UploadFile, Body(media_type=RequestEncodingType.MULTI_PART)],
12 | ) -> str:
13 | content = await data.read()
14 | filename = data.filename
15 | return f"{filename},length: {len(content)}"
16 |
17 |
18 | app = Litestar(route_handlers=[handle_file_upload])
19 |
--------------------------------------------------------------------------------
/docs/examples/responses/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/responses/__init__.py
--------------------------------------------------------------------------------
/docs/examples/responses/background_tasks_2.py:
--------------------------------------------------------------------------------
1 | import logging
2 | from typing import Dict
3 |
4 | from litestar import Litestar, get
5 | from litestar.background_tasks import BackgroundTask
6 |
7 | logger = logging.getLogger(__name__)
8 |
9 |
10 | async def logging_task(identifier: str, message: str) -> None:
11 | logger.info("%s: %s", identifier, message)
12 |
13 |
14 | @get("/", background=BackgroundTask(logging_task, "greeter", message="was called"), sync_to_thread=False)
15 | def greeter() -> Dict[str, str]:
16 | return {"hello": "world"}
17 |
18 |
19 | app = Litestar(route_handlers=[greeter])
20 |
--------------------------------------------------------------------------------
/docs/examples/responses/custom_responses.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, Response, get
2 | from litestar.datastructures import MultiDict
3 |
4 |
5 | class MultiDictResponse(Response):
6 | type_encoders = {MultiDict: lambda d: d.dict()}
7 |
8 |
9 | @get("/")
10 | async def index() -> MultiDict:
11 | return MultiDict([("foo", "bar"), ("foo", "baz")])
12 |
13 |
14 | app = Litestar([index], response_class=MultiDictResponse)
15 |
16 |
17 | # run: /
18 |
--------------------------------------------------------------------------------
/docs/examples/responses/json_suffix_responses.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict
2 |
3 | import litestar.status_codes
4 | from litestar import Litestar, get
5 |
6 |
7 | @get(
8 | "/resources",
9 | status_code=litestar.status_codes.HTTP_418_IM_A_TEAPOT,
10 | media_type="application/vnd.example.resource+json",
11 | )
12 | async def retrieve_resource() -> Dict[str, Any]:
13 | return {
14 | "title": "Server thinks it is a teapot",
15 | "type": "Server delusion",
16 | "status": litestar.status_codes.HTTP_418_IM_A_TEAPOT,
17 | }
18 |
19 |
20 | app = Litestar(route_handlers=[retrieve_resource])
21 |
--------------------------------------------------------------------------------
/docs/examples/responses/response_cookies_2.py:
--------------------------------------------------------------------------------
1 | from litestar import Controller, Litestar, MediaType, get
2 | from litestar.datastructures import Cookie
3 |
4 |
5 | class MyController(Controller):
6 | path = "/controller-path"
7 | response_cookies = [Cookie(key="my-cookie", value="123")]
8 |
9 | @get(
10 | path="/",
11 | response_cookies=[Cookie(key="my-cookie", value="456")],
12 | media_type=MediaType.TEXT,
13 | sync_to_thread=False,
14 | )
15 | def my_route_handler(self) -> str:
16 | return "hello world"
17 |
18 |
19 | app = Litestar(route_handlers=[MyController])
20 |
--------------------------------------------------------------------------------
/docs/examples/responses/streaming_responses.py:
--------------------------------------------------------------------------------
1 | from asyncio import sleep
2 | from datetime import datetime
3 | from typing import AsyncGenerator
4 |
5 | from litestar import Litestar, get
6 | from litestar.response import Stream
7 | from litestar.serialization import encode_json
8 |
9 |
10 | async def my_generator() -> AsyncGenerator[bytes, None]:
11 | while True:
12 | await sleep(0.01)
13 | yield encode_json({"current_time": datetime.now()})
14 |
15 |
16 | @get(path="/time")
17 | def stream_time() -> Stream:
18 | return Stream(my_generator())
19 |
20 |
21 | app = Litestar(route_handlers=[stream_time])
22 |
--------------------------------------------------------------------------------
/docs/examples/routing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/routing/__init__.py
--------------------------------------------------------------------------------
/docs/examples/security/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/security/__init__.py
--------------------------------------------------------------------------------
/docs/examples/security/jwt/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/security/jwt/__init__.py
--------------------------------------------------------------------------------
/docs/examples/signature_namespace/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/signature_namespace/__init__.py
--------------------------------------------------------------------------------
/docs/examples/signature_namespace/app.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar import Litestar
4 |
5 | from .controller import MyController
6 | from .domain import Model
7 |
8 | app = Litestar(route_handlers=[MyController], signature_types=[Model])
9 |
--------------------------------------------------------------------------------
/docs/examples/signature_namespace/controller.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import TYPE_CHECKING
4 |
5 | from litestar import Controller, post
6 |
7 | if TYPE_CHECKING:
8 | from .domain import Model
9 |
10 |
11 | class MyController(Controller):
12 | @post(sync_to_thread=False)
13 | def post_handler(self, data: Model) -> Model:
14 | return data
15 |
--------------------------------------------------------------------------------
/docs/examples/signature_namespace/domain.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from dataclasses import dataclass
4 |
5 |
6 | @dataclass
7 | class Model:
8 | a: int
9 | b: str
10 |
--------------------------------------------------------------------------------
/docs/examples/static_files/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/static_files/__init__.py
--------------------------------------------------------------------------------
/docs/examples/static_files/custom_router.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.router import Router
3 | from litestar.static_files import create_static_files_router
4 |
5 |
6 | class MyRouter(Router):
7 | pass
8 |
9 |
10 | app = Litestar(
11 | route_handlers=[
12 | create_static_files_router(
13 | path="/static",
14 | directories=["assets"],
15 | router_class=MyRouter,
16 | )
17 | ]
18 | )
19 |
--------------------------------------------------------------------------------
/docs/examples/static_files/file_system.py:
--------------------------------------------------------------------------------
1 | from fsspec.implementations.ftp import FTPFileSystem
2 |
3 | from litestar import Litestar
4 | from litestar.static_files import create_static_files_router
5 |
6 | app = Litestar(
7 | route_handlers=[
8 | create_static_files_router(
9 | path="/static",
10 | directories=["assets"],
11 | file_system=FTPFileSystem(host="127.0.0.1"),
12 | ),
13 | ]
14 | )
15 |
--------------------------------------------------------------------------------
/docs/examples/static_files/full_example.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.static_files import create_static_files_router
5 |
6 | ASSETS_DIR = Path("assets")
7 |
8 |
9 | def on_startup():
10 | ASSETS_DIR.mkdir(exist_ok=True)
11 | ASSETS_DIR.joinpath("hello.txt").write_text("Hello, world!")
12 |
13 |
14 | app = Litestar(
15 | route_handlers=[
16 | create_static_files_router(path="/static", directories=["assets"]),
17 | ],
18 | on_startup=[on_startup],
19 | )
20 |
21 |
22 | # run: /static/hello.txt
23 |
--------------------------------------------------------------------------------
/docs/examples/static_files/passing_options.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.static_files import create_static_files_router
3 |
4 | app = Litestar(
5 | route_handlers=[
6 | create_static_files_router(
7 | path="/",
8 | directories=["assets"],
9 | opt={"some": True},
10 | include_in_schema=False,
11 | tags=["static"],
12 | )
13 | ]
14 | )
15 |
--------------------------------------------------------------------------------
/docs/examples/static_files/route_reverse.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.static_files import create_static_files_router
3 |
4 | app = Litestar(
5 | route_handlers=[
6 | create_static_files_router(path="/static", directories=["assets"]),
7 | ]
8 | )
9 |
10 |
11 | print(app.route_reverse(name="static", file_path="/some_file.txt")) # /static/some_file.txt
12 |
--------------------------------------------------------------------------------
/docs/examples/static_files/send_as_attachment.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.static_files import create_static_files_router
3 |
4 | app = Litestar(
5 | route_handlers=[
6 | create_static_files_router(
7 | path="/static",
8 | directories=["assets"],
9 | send_as_attachment=True,
10 | )
11 | ]
12 | )
13 |
--------------------------------------------------------------------------------
/docs/examples/static_files/upgrade_from_static_1.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.static_files.config import StaticFilesConfig
3 |
4 | app = Litestar(
5 | static_files_config=[
6 | StaticFilesConfig(directories=["assets"], path="/static"),
7 | ],
8 | )
9 |
--------------------------------------------------------------------------------
/docs/examples/static_files/upgrade_from_static_2.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.static_files import create_static_files_router
3 |
4 | app = Litestar(
5 | route_handlers=[
6 | create_static_files_router(directories=["assets"], path="/static"),
7 | ],
8 | )
9 |
--------------------------------------------------------------------------------
/docs/examples/stores/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/stores/__init__.py
--------------------------------------------------------------------------------
/docs/examples/stores/delete_expired_after_response.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime, timedelta
2 |
3 | from litestar import Litestar, Request
4 | from litestar.stores.memory import MemoryStore
5 |
6 | memory_store = MemoryStore()
7 |
8 |
9 | async def after_response(request: Request) -> None:
10 | now = datetime.utcnow()
11 | last_cleared = request.app.state.get("store_last_cleared", now)
12 | if datetime.utcnow() - last_cleared > timedelta(seconds=30):
13 | await memory_store.delete_expired()
14 | app.state["store_last_cleared"] = now
15 |
16 |
17 | app = Litestar(after_response=after_response)
18 |
--------------------------------------------------------------------------------
/docs/examples/stores/delete_expired_on_startup.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.stores.file import FileStore
5 |
6 | file_store = FileStore(Path("data"))
7 |
8 |
9 | async def on_startup() -> None:
10 | await file_store.delete_expired()
11 |
12 |
13 | app = Litestar(on_startup=[on_startup])
14 |
--------------------------------------------------------------------------------
/docs/examples/stores/expiry.py:
--------------------------------------------------------------------------------
1 | from asyncio import sleep
2 |
3 | from litestar.stores.memory import MemoryStore
4 |
5 | store = MemoryStore()
6 |
7 |
8 | async def main() -> None:
9 | await store.set("foo", b"bar", expires_in=1)
10 | value = await store.get("foo")
11 | print(value)
12 |
13 | await sleep(1)
14 | value = await store.get("foo") # this will return 'None', since the key has expired
15 | print(value)
16 |
--------------------------------------------------------------------------------
/docs/examples/stores/expiry_renew_on_get.py:
--------------------------------------------------------------------------------
1 | from asyncio import sleep
2 |
3 | from litestar.stores.memory import MemoryStore
4 |
5 | store = MemoryStore()
6 |
7 |
8 | async def main() -> None:
9 | await store.set("foo", b"bar", expires_in=1)
10 | await sleep(0.5)
11 |
12 | await store.get("foo", renew_for=1) # this will reset the time to live to one second
13 |
14 | await sleep(1)
15 | # it has now been 1.5 seconds since the key was set with a life time of one second,
16 | # so it should have expired however, since it was renewed for one second, it is still available
17 | value = await store.get("foo")
18 | print(value)
19 |
--------------------------------------------------------------------------------
/docs/examples/stores/get_set.py:
--------------------------------------------------------------------------------
1 | from litestar.stores.memory import MemoryStore
2 |
3 | store = MemoryStore()
4 |
5 |
6 | async def main() -> None:
7 | value = await store.get("key")
8 | print(value) # this will print 'None', as no store with this key has been defined yet
9 |
10 | await store.set("key", b"value")
11 | value = await store.get("key")
12 | print(value)
13 |
--------------------------------------------------------------------------------
/docs/examples/stores/namespacing.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.stores.redis import RedisStore
3 |
4 | root_store = RedisStore.with_client()
5 | cache_store = root_store.with_namespace("cache")
6 | session_store = root_store.with_namespace("sessions")
7 |
8 |
9 | async def before_shutdown() -> None:
10 | await cache_store.delete_all()
11 |
12 |
13 | app = Litestar(before_shutdown=[before_shutdown])
14 |
--------------------------------------------------------------------------------
/docs/examples/stores/registry.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.stores.memory import MemoryStore
3 |
4 | app = Litestar([], stores={"memory": MemoryStore()})
5 |
6 | memory_store = app.stores.get("memory")
7 | # this is the previously defined store
8 |
9 | some_other_store = app.stores.get("something_else")
10 | # this will be a newly created instance
11 |
12 | assert app.stores.get("something_else") is some_other_store
13 | # but subsequent requests will return the same instance
14 |
--------------------------------------------------------------------------------
/docs/examples/stores/registry_access_integration.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.middleware.rate_limit import RateLimitConfig
3 |
4 | app = Litestar(middleware=[RateLimitConfig(("second", 1)).middleware])
5 | rate_limit_store = app.stores.get("rate_limit")
6 |
--------------------------------------------------------------------------------
/docs/examples/stores/registry_configure_integrations.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.middleware.session.server_side import ServerSideSessionConfig
5 | from litestar.stores.file import FileStore
6 | from litestar.stores.redis import RedisStore
7 |
8 | app = Litestar(
9 | stores={
10 | "sessions": RedisStore.with_client(),
11 | "response_cache": FileStore(Path("response-cache")),
12 | },
13 | middleware=[ServerSideSessionConfig().middleware],
14 | )
15 |
--------------------------------------------------------------------------------
/docs/examples/stores/registry_default_factory.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar
2 | from litestar.stores.memory import MemoryStore
3 | from litestar.stores.registry import StoreRegistry
4 |
5 | memory_store = MemoryStore()
6 |
7 |
8 | def default_factory(name: str) -> MemoryStore:
9 | return memory_store
10 |
11 |
12 | app = Litestar([], stores=StoreRegistry(default_factory=default_factory))
13 |
--------------------------------------------------------------------------------
/docs/examples/templating/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/templating/__init__.py
--------------------------------------------------------------------------------
/docs/examples/templating/engine_instance_jinja.py:
--------------------------------------------------------------------------------
1 | from litestar.contrib.jinja import JinjaTemplateEngine
2 | from litestar.template.config import TemplateConfig
3 |
4 | template_config = TemplateConfig(engine=JinjaTemplateEngine, directory="templates")
5 |
--------------------------------------------------------------------------------
/docs/examples/templating/engine_instance_mako.py:
--------------------------------------------------------------------------------
1 | from litestar.contrib.mako import MakoTemplateEngine
2 | from litestar.template.config import TemplateConfig
3 |
4 | template_config = TemplateConfig(engine=MakoTemplateEngine, directory="templates")
5 |
--------------------------------------------------------------------------------
/docs/examples/templating/engine_instance_minijinja.py:
--------------------------------------------------------------------------------
1 | from litestar.contrib.minijinja import MiniJinjaTemplateEngine
2 | from litestar.template.config import TemplateConfig
3 |
4 | template_config = TemplateConfig(engine=MiniJinjaTemplateEngine, directory="templates")
5 |
--------------------------------------------------------------------------------
/docs/examples/templating/template_engine_jinja.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.contrib.jinja import JinjaTemplateEngine
5 | from litestar.template.config import TemplateConfig
6 |
7 | app = Litestar(
8 | route_handlers=[],
9 | template_config=TemplateConfig(
10 | directory=Path("templates"),
11 | engine=JinjaTemplateEngine,
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/templating/template_engine_mako.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.contrib.mako import MakoTemplateEngine
5 | from litestar.template.config import TemplateConfig
6 |
7 | app = Litestar(
8 | route_handlers=[],
9 | template_config=TemplateConfig(
10 | directory=Path("templates"),
11 | engine=MakoTemplateEngine,
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/templating/template_engine_minijinja.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar
4 | from litestar.contrib.minijinja import MiniJinjaTemplateEngine
5 | from litestar.template.config import TemplateConfig
6 |
7 | app = Litestar(
8 | route_handlers=[],
9 | template_config=TemplateConfig(
10 | directory=Path("templates"),
11 | engine=MiniJinjaTemplateEngine,
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/hello.html.jinja2:
--------------------------------------------------------------------------------
1 | Hello {{ name }}
2 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/hello.html.mako:
--------------------------------------------------------------------------------
1 | Hello ${ name }
2 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/hello.html.minijinja:
--------------------------------------------------------------------------------
1 | Hello {{ name }}
2 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/index.html.jinja2:
--------------------------------------------------------------------------------
1 | check_context_key: {{ check_context_key() }}
2 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/index.html.mako:
--------------------------------------------------------------------------------
1 | check_context_key: ${ check_context_key() }
2 |
--------------------------------------------------------------------------------
/docs/examples/templating/templates/index.html.minijinja:
--------------------------------------------------------------------------------
1 | check_context_key: {{ check_context_key() }}
2 |
--------------------------------------------------------------------------------
/docs/examples/testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/testing/__init__.py
--------------------------------------------------------------------------------
/docs/examples/todo_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/todo_app/__init__.py
--------------------------------------------------------------------------------
/docs/examples/todo_app/create/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/todo_app/create/__init__.py
--------------------------------------------------------------------------------
/docs/examples/todo_app/create/dataclass.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 | from typing import List
3 |
4 | from litestar import Litestar, post
5 |
6 |
7 | @dataclass
8 | class TodoItem:
9 | title: str
10 | done: bool
11 |
12 |
13 | TODO_LIST: List[TodoItem] = []
14 |
15 |
16 | @post("/")
17 | async def add_item(data: TodoItem) -> List[TodoItem]:
18 | TODO_LIST.append(data)
19 | return TODO_LIST
20 |
21 |
22 | app = Litestar([add_item])
23 |
--------------------------------------------------------------------------------
/docs/examples/todo_app/create/dict.py:
--------------------------------------------------------------------------------
1 | from typing import Any, Dict, List, Union
2 |
3 | from litestar import Litestar, post
4 |
5 | TODO_LIST: List[Dict[str, Union[str, bool]]] = []
6 |
7 |
8 | @post("/")
9 | async def add_item(data: Dict[str, Any]) -> List[Dict[str, Union[str, bool]]]:
10 | TODO_LIST.append(data)
11 | return TODO_LIST
12 |
13 |
14 | app = Litestar([add_item])
15 |
--------------------------------------------------------------------------------
/docs/examples/todo_app/get_list/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/todo_app/get_list/__init__.py
--------------------------------------------------------------------------------
/docs/examples/todo_app/get_list/dataclass.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 | from typing import List
3 |
4 | from litestar import Litestar, get
5 |
6 |
7 | @dataclass
8 | class TodoItem:
9 | title: str
10 | done: bool
11 |
12 |
13 | TODO_LIST: List[TodoItem] = [
14 | TodoItem(title="Start writing TODO list", done=True),
15 | TodoItem(title="???", done=False),
16 | TodoItem(title="Profit", done=False),
17 | ]
18 |
19 |
20 | @get("/")
21 | async def get_list() -> List[TodoItem]:
22 | return TODO_LIST
23 |
24 |
25 | app = Litestar([get_list])
26 |
--------------------------------------------------------------------------------
/docs/examples/todo_app/get_list/dict.py:
--------------------------------------------------------------------------------
1 | from typing import Dict, List, Union
2 |
3 | from litestar import Litestar, get
4 |
5 | TODO_LIST: List[Dict[str, Union[str, bool]]] = [
6 | {"title": "Start writing TODO list", "done": True},
7 | {"title": "???", "done": False},
8 | {"title": "Profit", "done": False},
9 | ]
10 |
11 |
12 | @get("/")
13 | async def get_list() -> List[Dict[str, Union[str, bool]]]:
14 | return TODO_LIST
15 |
16 |
17 | app = Litestar([get_list])
18 |
--------------------------------------------------------------------------------
/docs/examples/todo_app/get_list/query_param_validate.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 | from typing import List
3 |
4 | from litestar import Litestar, get
5 |
6 |
7 | @dataclass
8 | class TodoItem:
9 | title: str
10 | done: bool
11 |
12 |
13 | TODO_LIST: List[TodoItem] = [
14 | TodoItem(title="Start writing TODO list", done=True),
15 | TodoItem(title="???", done=False),
16 | TodoItem(title="Profit", done=False),
17 | ]
18 |
19 |
20 | @get("/")
21 | async def get_list(done: bool) -> List[TodoItem]:
22 | return [item for item in TODO_LIST if item.done == done]
23 |
24 |
25 | app = Litestar([get_list])
26 |
--------------------------------------------------------------------------------
/docs/examples/todo_app/hello_world.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, get
2 |
3 |
4 | @get("/")
5 | async def hello_world() -> str:
6 | return "Hello, world!"
7 |
8 |
9 | app = Litestar([hello_world])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/examples/websockets/__init__.py
--------------------------------------------------------------------------------
/docs/examples/websockets/dependency_injection_simple.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 | from litestar.di import Provide
3 |
4 |
5 | def some_dependency() -> str:
6 | return "hello"
7 |
8 |
9 | @websocket_listener("/", dependencies={"some": Provide(some_dependency)})
10 | async def handler(data: str, some: str) -> str:
11 | return data + some
12 |
13 |
14 | app = Litestar([handler])
15 |
--------------------------------------------------------------------------------
/docs/examples/websockets/listener_class_based.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, WebSocket
2 | from litestar.handlers import WebsocketListener
3 |
4 |
5 | class Handler(WebsocketListener):
6 | path = "/"
7 |
8 | def on_accept(self, socket: WebSocket) -> None:
9 | print("Connection accepted")
10 |
11 | def on_disconnect(self, socket: WebSocket) -> None:
12 | print("Connection closed")
13 |
14 | def on_receive(self, data: str) -> str:
15 | return data
16 |
17 |
18 | app = Litestar([Handler])
19 |
--------------------------------------------------------------------------------
/docs/examples/websockets/listener_class_based_async.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, WebSocket
2 | from litestar.handlers import WebsocketListener
3 |
4 |
5 | class Handler(WebsocketListener):
6 | path = "/"
7 |
8 | async def on_accept(self, socket: WebSocket) -> None:
9 | print("Connection accepted")
10 |
11 | async def on_disconnect(self, socket: WebSocket) -> None:
12 | print("Connection closed")
13 |
14 | async def on_receive(self, data: str) -> str:
15 | return data
16 |
17 |
18 | app = Litestar([Handler])
19 |
--------------------------------------------------------------------------------
/docs/examples/websockets/mode_receive_binary.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/", receive_mode="binary")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/mode_receive_text.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/", receive_mode="text")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/mode_send_binary.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/", send_mode="binary")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/mode_send_text.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/", send_mode="text")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/receive_bytes.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/")
5 | async def handler(data: bytes) -> str:
6 | return data.decode("utf-8")
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/receive_json.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, websocket_listener
4 |
5 |
6 | @websocket_listener("/")
7 | async def handler(data: Dict[str, str]) -> Dict[str, str]:
8 | return data
9 |
10 |
11 | app = Litestar([handler])
12 |
--------------------------------------------------------------------------------
/docs/examples/websockets/receive_str.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/sending_bytes.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/")
5 | async def handler(data: str) -> bytes:
6 | return data.encode("utf-8")
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/sending_json_dataclass.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 | from datetime import datetime
3 |
4 | from litestar import Litestar, websocket_listener
5 |
6 |
7 | @dataclass
8 | class Message:
9 | content: str
10 | timestamp: float
11 |
12 |
13 | @websocket_listener("/")
14 | async def handler(data: str) -> Message:
15 | return Message(content=data, timestamp=datetime.now().timestamp())
16 |
17 |
18 | app = Litestar([handler])
19 |
--------------------------------------------------------------------------------
/docs/examples/websockets/sending_json_dict.py:
--------------------------------------------------------------------------------
1 | from typing import Dict
2 |
3 | from litestar import Litestar, websocket_listener
4 |
5 |
6 | @websocket_listener("/")
7 | async def handler(data: str) -> Dict[str, str]:
8 | return {"message": data}
9 |
10 |
11 | app = Litestar([handler])
12 |
--------------------------------------------------------------------------------
/docs/examples/websockets/sending_str.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, websocket_listener
2 |
3 |
4 | @websocket_listener("/")
5 | async def handler(data: str) -> str:
6 | return data
7 |
8 |
9 | app = Litestar([handler])
10 |
--------------------------------------------------------------------------------
/docs/examples/websockets/setting_custom_connection_headers.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, WebSocket, websocket_listener
2 |
3 |
4 | async def accept_connection(socket: WebSocket) -> None:
5 | await socket.accept(headers={"Cookie": "custom-cookie"})
6 |
7 |
8 | @websocket_listener("/", connection_accept_handler=accept_connection)
9 | def handler(data: str) -> str:
10 | return data
11 |
12 |
13 | app = Litestar([handler])
14 |
--------------------------------------------------------------------------------
/docs/examples/websockets/socket_access.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, WebSocket, websocket_listener
2 |
3 |
4 | @websocket_listener("/")
5 | async def handler(data: str, socket: WebSocket) -> str:
6 | if data == "goodbye":
7 | await socket.close()
8 |
9 | return data
10 |
11 |
12 | app = Litestar([handler])
13 |
--------------------------------------------------------------------------------
/docs/examples/websockets/stream_basic.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import time
3 | from typing import AsyncGenerator
4 |
5 | from litestar import Litestar, websocket_stream
6 |
7 |
8 | @websocket_stream("/")
9 | async def ping() -> AsyncGenerator[float, None]:
10 | while True:
11 | yield time.time()
12 | await asyncio.sleep(0.5)
13 |
14 |
15 | app = Litestar([ping])
16 |
--------------------------------------------------------------------------------
/docs/examples/websockets/stream_di_hog_fix.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | from typing import AsyncGenerator
3 |
4 | from app.lib import ping_external_resource
5 | from litestar import Litestar, websocket_stream
6 |
7 | RESOURCE_LOCK = asyncio.Lock()
8 |
9 |
10 | @websocket_stream("/")
11 | async def ping() -> AsyncGenerator[float, None]:
12 | while True:
13 | async with RESOURCE_LOCK:
14 | alive = await ping_external_resource()
15 | yield alive
16 | await asyncio.sleep(1)
17 |
18 |
19 | app = Litestar([ping])
20 |
--------------------------------------------------------------------------------
/docs/examples/websockets/stream_socket_access.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import time
3 | from typing import Any, AsyncGenerator
4 |
5 | from litestar import Litestar, WebSocket, websocket_stream
6 |
7 |
8 | @websocket_stream("/")
9 | async def ping(socket: WebSocket) -> AsyncGenerator[dict[str, Any], None]:
10 | while True:
11 | yield {"time": time.time(), "client": socket.client}
12 | await asyncio.sleep(0.5)
13 |
14 |
15 | app = Litestar([ping])
16 |
--------------------------------------------------------------------------------
/docs/examples/websockets/with_dto.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy.orm import Mapped
2 |
3 | from litestar import Litestar, websocket_listener
4 | from litestar.plugins.sqlalchemy import SQLAlchemyDTO, base
5 |
6 |
7 | class User(base.UUIDBase):
8 | name: Mapped[str]
9 |
10 |
11 | UserDTO = SQLAlchemyDTO[User]
12 |
13 |
14 | @websocket_listener("/", dto=UserDTO)
15 | async def handler(data: User) -> User:
16 | return data
17 |
18 |
19 | app = Litestar([handler])
20 |
--------------------------------------------------------------------------------
/docs/images/cli/litestar_info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/cli/litestar_info.png
--------------------------------------------------------------------------------
/docs/images/cli/litestar_routes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/cli/litestar_routes.png
--------------------------------------------------------------------------------
/docs/images/debugging/pycharm-config-cli.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/pycharm-config-cli.png
--------------------------------------------------------------------------------
/docs/images/debugging/pycharm-config-uvicorn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/pycharm-config-uvicorn.png
--------------------------------------------------------------------------------
/docs/images/debugging/pycharm-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/pycharm-debug.png
--------------------------------------------------------------------------------
/docs/images/debugging/vs-code-add-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/vs-code-add-config.png
--------------------------------------------------------------------------------
/docs/images/debugging/vs-code-config-litestar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/vs-code-config-litestar.png
--------------------------------------------------------------------------------
/docs/images/debugging/vs-code-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/vs-code-debug.png
--------------------------------------------------------------------------------
/docs/images/debugging/vs-code-select-config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/debugging/vs-code-select-config.png
--------------------------------------------------------------------------------
/docs/images/examples/template_engine_callable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/examples/template_engine_callable.png
--------------------------------------------------------------------------------
/docs/images/exception-handlers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/images/exception-handlers.jpg
--------------------------------------------------------------------------------
/docs/migration/index.rst:
--------------------------------------------------------------------------------
1 | Migrating to Litestar
2 | =====================
3 |
4 | Migrating from `Starlette `_ or
5 | `FastAPI `_ to Litestar is straightforward, as they are both
6 | ASGI frameworks and as such build on the same fundamental principles. The following sections
7 | can help to navigate a migration from either framework by introducing Litestar-equivalents
8 | to common functionalities.
9 |
10 |
11 | .. toctree::
12 | :titlesonly:
13 |
14 | flask
15 | fastapi
16 |
--------------------------------------------------------------------------------
/docs/reference/app.rst:
--------------------------------------------------------------------------------
1 | app
2 | ===
3 |
4 | .. automodule:: litestar.app
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/background_tasks.rst:
--------------------------------------------------------------------------------
1 | background_tasks
2 | ================
3 |
4 | .. automodule:: litestar.background_tasks
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/asyncpg.rst:
--------------------------------------------------------------------------------
1 | asyncpg
2 | =======
3 |
4 | .. automodule:: litestar.channels.backends.asyncpg
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/base.rst:
--------------------------------------------------------------------------------
1 | base
2 | =====
3 |
4 | .. automodule:: litestar.channels.backends.base
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/index.rst:
--------------------------------------------------------------------------------
1 | backends
2 | ========
3 |
4 | .. toctree::
5 |
6 | base
7 | memory
8 | redis
9 | psycopg
10 | asyncpg
11 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/memory.rst:
--------------------------------------------------------------------------------
1 | memory
2 | ======
3 |
4 | .. automodule:: litestar.channels.backends.memory
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/psycopg.rst:
--------------------------------------------------------------------------------
1 | psycopg
2 | =======
3 |
4 | .. automodule:: litestar.channels.backends.psycopg
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/backends/redis.rst:
--------------------------------------------------------------------------------
1 | redis
2 | =====
3 |
4 | .. automodule:: litestar.channels.backends.redis
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/channels/index.rst:
--------------------------------------------------------------------------------
1 | channels
2 | ========
3 |
4 | .. toctree::
5 |
6 | plugin
7 | subscriber
8 | backends/index
9 |
--------------------------------------------------------------------------------
/docs/reference/channels/plugin.rst:
--------------------------------------------------------------------------------
1 | plugin
2 | ======
3 |
4 | .. autoclass:: litestar.channels.plugin.ChannelsPlugin
5 |
6 | .. autoclass:: litestar.channels.plugin.ChannelsException
7 |
--------------------------------------------------------------------------------
/docs/reference/channels/subscriber.rst:
--------------------------------------------------------------------------------
1 | subscriber
2 | ==========
3 |
4 | .. autoclass:: litestar.channels.subscriber.Subscriber
5 |
--------------------------------------------------------------------------------
/docs/reference/cli.rst:
--------------------------------------------------------------------------------
1 | cli
2 | ===
3 |
4 | .. automodule:: litestar.cli
5 | :members:
6 |
7 | .. click:: litestar.cli:litestar_group
8 | :prog: litestar
9 | :nested: full
10 |
--------------------------------------------------------------------------------
/docs/reference/concurrency.rst:
--------------------------------------------------------------------------------
1 | concurrency
2 | ===========
3 |
4 | .. automodule:: litestar.concurrency
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/config.rst:
--------------------------------------------------------------------------------
1 | config
2 | ======
3 |
4 |
5 | .. automodule:: litestar.config.allowed_hosts
6 | :members:
7 |
8 | .. automodule:: litestar.config.app
9 | :members:
10 |
11 | .. automodule:: litestar.config.compression
12 | :members:
13 |
14 | .. automodule:: litestar.config.cors
15 | :members:
16 |
17 | .. automodule:: litestar.config.csrf
18 | :members:
19 |
20 | .. automodule:: litestar.config.response_cache
21 | :members:
22 |
--------------------------------------------------------------------------------
/docs/reference/connection.rst:
--------------------------------------------------------------------------------
1 | connection
2 | ==========
3 |
4 | .. automodule:: litestar.connection
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/htmx.rst:
--------------------------------------------------------------------------------
1 | HTMX
2 | ====
3 |
4 | Request
5 | -------
6 |
7 | .. automodule:: litestar.contrib.htmx.request
8 | :members:
9 |
10 | Response
11 | --------
12 |
13 | .. automodule:: litestar.contrib.htmx.response
14 | :members:
15 |
--------------------------------------------------------------------------------
/docs/reference/contrib/index.rst:
--------------------------------------------------------------------------------
1 | contrib
2 | =======
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | htmx
8 | jinja
9 | jwt
10 | mako
11 | opentelemetry
12 | piccolo
13 | pydantic
14 | sqlalchemy/index
15 |
--------------------------------------------------------------------------------
/docs/reference/contrib/jinja.rst:
--------------------------------------------------------------------------------
1 | jinja
2 | =====
3 |
4 | .. automodule:: litestar.contrib.jinja
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/jwt.rst:
--------------------------------------------------------------------------------
1 | jwt
2 | ===
3 |
4 | This page has moved to :doc:`/reference/security/jwt`
5 |
--------------------------------------------------------------------------------
/docs/reference/contrib/mako.rst:
--------------------------------------------------------------------------------
1 | mako
2 | ====
3 |
4 | .. automodule:: litestar.contrib.mako
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/opentelemetry.rst:
--------------------------------------------------------------------------------
1 | opentelemetry
2 | =============
3 |
4 | .. automodule:: litestar.contrib.opentelemetry
5 | :members:
6 |
7 | .. autoclass:: litestar.contrib.opentelemetry.config.OpenTelemetryHookHandler
8 |
--------------------------------------------------------------------------------
/docs/reference/contrib/piccolo.rst:
--------------------------------------------------------------------------------
1 | piccolo_orm
2 | ===========
3 |
4 | .. automodule:: litestar.contrib.piccolo
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/pydantic.rst:
--------------------------------------------------------------------------------
1 | pydantic
2 | ========
3 |
4 | .. automodule:: litestar.contrib.pydantic
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/repository/abc.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | abc
4 | ===
5 |
6 | This page has moved to :doc:`/reference/repository/abc`
7 |
--------------------------------------------------------------------------------
/docs/reference/contrib/repository/exceptions.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | exceptions
4 | ==========
5 |
6 | This page has moved to :doc:`/reference/repository/exceptions`
7 |
--------------------------------------------------------------------------------
/docs/reference/contrib/repository/filters.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | filters
4 | =======
5 |
6 | This page has moved to :doc:`/reference/repository/filters`
7 |
--------------------------------------------------------------------------------
/docs/reference/contrib/repository/handlers.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | handlers
4 | =========
5 |
6 | This page has moved to :doc:`/reference/repository/handlers`
7 |
--------------------------------------------------------------------------------
/docs/reference/contrib/repository/testing.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | testing
4 | =======
5 |
6 | This page has moved to :doc:`/reference/repository/testing`
7 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/base.rst:
--------------------------------------------------------------------------------
1 | base
2 | ====
3 |
4 | .. automodule:: litestar.contrib.sqlalchemy.base
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/dto.rst:
--------------------------------------------------------------------------------
1 | DTO
2 | ===
3 |
4 | This page has moved to :doc:`advanced-alchemy:reference/extensions/litestar/dto`
5 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/index.rst:
--------------------------------------------------------------------------------
1 | sqlalchemy
2 | ==========
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | plugins
8 | repository
9 | types
10 | base
11 | dto
12 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/plugins.rst:
--------------------------------------------------------------------------------
1 | plugins
2 | =======
3 |
4 | .. automodule:: litestar.contrib.sqlalchemy.plugins
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/repository.rst:
--------------------------------------------------------------------------------
1 | repository
2 | ==========
3 |
4 | This page has moved to :doc:`advanced-alchemy:reference/repository`
5 |
--------------------------------------------------------------------------------
/docs/reference/contrib/sqlalchemy/types.rst:
--------------------------------------------------------------------------------
1 | types
2 | =====
3 |
4 | This page has moved to :doc:`advanced-alchemy:reference/types`
5 |
--------------------------------------------------------------------------------
/docs/reference/controller.rst:
--------------------------------------------------------------------------------
1 | controller
2 | ==========
3 |
4 | .. automodule:: litestar.controller
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/data_extractors.rst:
--------------------------------------------------------------------------------
1 | data_extractors
2 | ===============
3 |
4 |
5 | .. automodule:: litestar.data_extractors
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/datastructures/index.rst:
--------------------------------------------------------------------------------
1 | datastructures
2 | ==============
3 |
4 | .. automodule:: litestar.datastructures
5 | :members:
6 |
7 | .. toctree::
8 | :maxdepth: 1
9 |
10 | secret_values
11 |
--------------------------------------------------------------------------------
/docs/reference/datastructures/secret_values.rst:
--------------------------------------------------------------------------------
1 | secret_values
2 | =============
3 |
4 | .. automodule:: litestar.datastructures.secret_values
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/di.rst:
--------------------------------------------------------------------------------
1 | di
2 | --
3 |
4 | .. automodule:: litestar.di
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/base_dto.rst:
--------------------------------------------------------------------------------
1 | base_dto
2 | ========
3 |
4 | .. automodule:: litestar.dto.base_dto
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/config.rst:
--------------------------------------------------------------------------------
1 | config
2 | ======
3 |
4 | .. automodule:: litestar.dto.config
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/data_structures.rst:
--------------------------------------------------------------------------------
1 | data_structures
2 | ===============
3 |
4 | .. automodule:: litestar.dto.data_structures
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/dataclass_dto.rst:
--------------------------------------------------------------------------------
1 | dataclass_dto
2 | =============
3 |
4 | .. automodule:: litestar.dto.dataclass_dto
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/field.rst:
--------------------------------------------------------------------------------
1 | field
2 | =====
3 |
4 | .. automodule:: litestar.dto.field
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/index.rst:
--------------------------------------------------------------------------------
1 | dto
2 | ===
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | config
8 | data_structures
9 | field
10 | types
11 | base_dto
12 | msgspec_dto
13 | dataclass_dto
14 |
--------------------------------------------------------------------------------
/docs/reference/dto/msgspec_dto.rst:
--------------------------------------------------------------------------------
1 | msgspec_dto
2 | ===========
3 |
4 | .. automodule:: litestar.dto.msgspec_dto
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/dto/types.rst:
--------------------------------------------------------------------------------
1 | types
2 | =====
3 |
4 | .. automodule:: litestar.dto.types
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/enums.rst:
--------------------------------------------------------------------------------
1 | enums
2 | =====
3 |
4 | .. automodule:: litestar.enums
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/events.rst:
--------------------------------------------------------------------------------
1 | events
2 | ======
3 |
4 |
5 | .. automodule:: litestar.events
6 | :members: BaseEventEmitterBackend, SimpleEventEmitter, EventListener, listener
7 |
--------------------------------------------------------------------------------
/docs/reference/exceptions.rst:
--------------------------------------------------------------------------------
1 | exceptions
2 | ==========
3 |
4 | .. automodule:: litestar.exceptions
5 | :members:
6 |
7 | .. automodule:: litestar.exceptions.responses
8 | :members:
9 |
--------------------------------------------------------------------------------
/docs/reference/handlers.rst:
--------------------------------------------------------------------------------
1 | handlers
2 | ========
3 |
4 | .. automodule:: litestar.handlers
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/logging/config.rst:
--------------------------------------------------------------------------------
1 | config
2 | ======
3 |
4 | .. automodule:: litestar.logging.config
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/logging/index.rst:
--------------------------------------------------------------------------------
1 | logging
2 | =======
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | config
8 | picologging
9 | standard
10 |
--------------------------------------------------------------------------------
/docs/reference/logging/picologging.rst:
--------------------------------------------------------------------------------
1 | picologging
2 | ============
3 |
4 | .. automodule:: litestar.logging.picologging
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/logging/standard.rst:
--------------------------------------------------------------------------------
1 | standard
2 | ========
3 |
4 | .. automodule:: litestar.logging.standard
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/allowed_hosts.rst:
--------------------------------------------------------------------------------
1 | allowed_hosts
2 | =============
3 |
4 | .. automodule:: litestar.middleware.allowed_hosts
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/authentication.rst:
--------------------------------------------------------------------------------
1 | authentication
2 | ==============
3 |
4 | .. automodule:: litestar.middleware.authentication
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/compression.rst:
--------------------------------------------------------------------------------
1 | compression
2 | ============
3 |
4 | .. automodule:: litestar.middleware.compression
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/cors.rst:
--------------------------------------------------------------------------------
1 | cors
2 | ====
3 |
4 | .. automodule:: litestar.middleware.cors
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/csrf.rst:
--------------------------------------------------------------------------------
1 | csrf
2 | ====
3 |
4 | .. automodule:: litestar.middleware.csrf
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/index.rst:
--------------------------------------------------------------------------------
1 | middleware
2 | ==========
3 |
4 | .. automodule:: litestar.middleware
5 |
6 |
7 | .. toctree::
8 | :maxdepth: 1
9 |
10 | allowed_hosts
11 | authentication
12 | compression
13 | cors
14 | csrf
15 | logging
16 | rate_limit
17 | session/index
18 |
--------------------------------------------------------------------------------
/docs/reference/middleware/logging.rst:
--------------------------------------------------------------------------------
1 | logging
2 | =======
3 |
4 | .. automodule:: litestar.middleware.logging
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/rate_limit.rst:
--------------------------------------------------------------------------------
1 | rate_limit
2 | ==========
3 |
4 | .. automodule:: litestar.middleware.rate_limit
5 | :members:
6 |
7 | .. autoclass:: litestar.middleware.rate_limit.DurationUnit
8 |
--------------------------------------------------------------------------------
/docs/reference/middleware/session/base.rst:
--------------------------------------------------------------------------------
1 | base
2 | ====
3 |
4 | .. automodule:: litestar.middleware.session.base
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/middleware/session/client_side.rst:
--------------------------------------------------------------------------------
1 | client_side
2 | ===========
3 |
4 | .. automodule:: litestar.middleware.session.client_side
5 |
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/middleware/session/index.rst:
--------------------------------------------------------------------------------
1 | session
2 | =======
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | base
8 | client_side
9 | server_side
10 |
--------------------------------------------------------------------------------
/docs/reference/middleware/session/server_side.rst:
--------------------------------------------------------------------------------
1 | server_side
2 | ===========
3 |
4 | .. automodule:: litestar.middleware.session.server_side
5 |
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/openapi/index.rst:
--------------------------------------------------------------------------------
1 | openapi
2 | ========
3 |
4 |
5 | .. toctree::
6 | :maxdepth: 1
7 |
8 | openapi
9 | plugins
10 | spec
11 |
--------------------------------------------------------------------------------
/docs/reference/openapi/openapi.rst:
--------------------------------------------------------------------------------
1 | openapi
2 | =======
3 |
4 | .. automodule:: litestar.openapi
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/openapi/plugins.rst:
--------------------------------------------------------------------------------
1 | plugins
2 | =======
3 |
4 | .. automodule:: litestar.openapi.plugins
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/openapi/spec.rst:
--------------------------------------------------------------------------------
1 | spec
2 | ====
3 |
4 |
5 | .. automodule:: litestar.openapi.spec
6 | :members:
7 |
8 |
9 | .. autodata:: litestar.openapi.spec.SecurityRequirement
10 |
--------------------------------------------------------------------------------
/docs/reference/pagination.rst:
--------------------------------------------------------------------------------
1 | pagination
2 | ==========
3 |
4 | .. automodule:: litestar.pagination
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/params.rst:
--------------------------------------------------------------------------------
1 | params
2 | ======
3 |
4 | .. automodule:: litestar.params
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/plugins/attrs.rst:
--------------------------------------------------------------------------------
1 | attrs
2 | =====
3 |
4 | .. automodule:: litestar.plugins.attrs
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/plugins/flash_messages.rst:
--------------------------------------------------------------------------------
1 | =====
2 | flash
3 | =====
4 |
5 |
6 | .. automodule:: litestar.plugins.flash
7 | :members:
8 |
--------------------------------------------------------------------------------
/docs/reference/plugins/htmx.rst:
--------------------------------------------------------------------------------
1 | ====
2 | htmx
3 | ====
4 |
5 |
6 | .. automodule:: litestar.plugins.htmx
7 | :members:
8 |
--------------------------------------------------------------------------------
/docs/reference/plugins/index.rst:
--------------------------------------------------------------------------------
1 | =======
2 | plugins
3 | =======
4 |
5 | .. automodule:: litestar.plugins
6 | :members:
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 | :hidden:
11 |
12 | attrs
13 | flash_messages
14 | htmx
15 | problem_details
16 | prometheus
17 | pydantic
18 | structlog
19 | sqlalchemy
20 |
--------------------------------------------------------------------------------
/docs/reference/plugins/problem_details.rst:
--------------------------------------------------------------------------------
1 | ===============
2 | problem details
3 | ===============
4 |
5 |
6 | .. automodule:: litestar.plugins.problem_details
7 | :members:
8 |
--------------------------------------------------------------------------------
/docs/reference/plugins/prometheus.rst:
--------------------------------------------------------------------------------
1 | prometheus
2 | ==========
3 |
4 | .. automodule:: litestar.plugins.prometheus
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/plugins/pydantic.rst:
--------------------------------------------------------------------------------
1 | pydantic
2 | ========
3 |
4 | .. automodule:: litestar.plugins.pydantic
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/plugins/sqlalchemy.rst:
--------------------------------------------------------------------------------
1 | ==========
2 | sqlalchemy
3 | ==========
4 |
5 | .. automodule:: litestar.plugins.sqlalchemy
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/plugins/structlog.rst:
--------------------------------------------------------------------------------
1 | =========
2 | structlog
3 | =========
4 |
5 | .. automodule:: litestar.plugins.structlog
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/repository/abc.rst:
--------------------------------------------------------------------------------
1 | abc
2 | ===
3 |
4 | .. automodule:: litestar.repository.abc
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/repository/exceptions.rst:
--------------------------------------------------------------------------------
1 | exceptions
2 | ==========
3 |
4 | This page has moved to :doc:`advanced-alchemy:reference/filters`
5 |
--------------------------------------------------------------------------------
/docs/reference/repository/filters.rst:
--------------------------------------------------------------------------------
1 | filters
2 | =======
3 |
4 | This page has moved to :doc:`advanced-alchemy:reference/filters`
5 |
--------------------------------------------------------------------------------
/docs/reference/repository/handlers.rst:
--------------------------------------------------------------------------------
1 | handlers
2 | =========
3 |
4 | .. automodule:: litestar.repository.handlers
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/repository/index.rst:
--------------------------------------------------------------------------------
1 | repository
2 | ==========
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | abc
8 | filters
9 | exceptions
10 | testing
11 | handlers
12 |
--------------------------------------------------------------------------------
/docs/reference/repository/testing.rst:
--------------------------------------------------------------------------------
1 | testing
2 | =======
3 |
4 | .. automodule:: litestar.repository.testing
5 | :members: generic_mock_repository
6 |
--------------------------------------------------------------------------------
/docs/reference/response/base.rst:
--------------------------------------------------------------------------------
1 | base
2 | ====
3 |
4 | .. automodule:: litestar.response.base
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/response/file.rst:
--------------------------------------------------------------------------------
1 | file
2 | ====
3 |
4 | .. automodule:: litestar.response.file
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/response/index.rst:
--------------------------------------------------------------------------------
1 | response
2 | ========
3 |
4 | .. automodule:: litestar.response
5 | :members:
6 |
7 | .. toctree::
8 | :maxdepth: 1
9 | :hidden:
10 |
11 | base
12 | file
13 | redirect
14 | streaming
15 | sse
16 | template
17 |
--------------------------------------------------------------------------------
/docs/reference/response/redirect.rst:
--------------------------------------------------------------------------------
1 | redirect
2 | ========
3 |
4 | .. automodule:: litestar.response.redirect
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/response/sse.rst:
--------------------------------------------------------------------------------
1 | SSE (Server Sent Events)
2 | ========================
3 |
4 | .. automodule:: litestar.response.sse
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/response/streaming.rst:
--------------------------------------------------------------------------------
1 | streaming
2 | =========
3 |
4 | .. automodule:: litestar.response.streaming
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/response/template.rst:
--------------------------------------------------------------------------------
1 | template
2 | ========
3 |
4 | .. automodule:: litestar.response.template
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/router.rst:
--------------------------------------------------------------------------------
1 | router
2 | ======
3 |
4 | .. automodule:: litestar.router
5 | :members: Router
6 |
--------------------------------------------------------------------------------
/docs/reference/routes.rst:
--------------------------------------------------------------------------------
1 | routes
2 | ======
3 |
4 |
5 | .. automodule:: litestar.routes
6 | :members:
7 |
--------------------------------------------------------------------------------
/docs/reference/security/index.rst:
--------------------------------------------------------------------------------
1 | security
2 | ========
3 |
4 |
5 | .. automodule:: litestar.security
6 |
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 |
11 | jwt
12 | session_auth
13 |
--------------------------------------------------------------------------------
/docs/reference/security/jwt.rst:
--------------------------------------------------------------------------------
1 | jwt
2 | ===
3 |
4 | .. automodule:: litestar.security.jwt
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/security/session_auth.rst:
--------------------------------------------------------------------------------
1 | session_auth
2 | ============
3 |
4 | .. autoclass:: litestar.security.session_auth.SessionAuth
5 | :members:
6 |
7 | .. autoclass:: litestar.security.session_auth.middleware.SessionAuthMiddleware
8 | :members:
9 |
--------------------------------------------------------------------------------
/docs/reference/serialization.rst:
--------------------------------------------------------------------------------
1 | serialization
2 | =============
3 |
4 | .. automodule:: litestar.serialization
5 | :members: default_serializer, encode_json, decode_json, encode_msgpack, decode_msgpack
6 |
--------------------------------------------------------------------------------
/docs/reference/static_files.rst:
--------------------------------------------------------------------------------
1 | static_files
2 | ============
3 |
4 | .. automodule:: litestar.static_files
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/status_codes.rst:
--------------------------------------------------------------------------------
1 | status_code
2 | ===========
3 |
4 | .. automodule:: litestar.status_codes
5 |
--------------------------------------------------------------------------------
/docs/reference/stores/base.rst:
--------------------------------------------------------------------------------
1 | base
2 | ====
3 |
4 |
5 | .. automodule:: litestar.stores.base
6 |
7 | :members: Store, NamespacedStore
8 |
--------------------------------------------------------------------------------
/docs/reference/stores/file.rst:
--------------------------------------------------------------------------------
1 | file
2 | ====
3 |
4 | .. automodule:: litestar.stores.file
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/stores/index.rst:
--------------------------------------------------------------------------------
1 | stores
2 | ======
3 |
4 | .. toctree::
5 |
6 | base
7 | file
8 | memory
9 | redis
10 | registry
11 | valkey
12 |
--------------------------------------------------------------------------------
/docs/reference/stores/memory.rst:
--------------------------------------------------------------------------------
1 | memory
2 | ======
3 |
4 | .. automodule:: litestar.stores.memory
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/stores/redis.rst:
--------------------------------------------------------------------------------
1 | redis
2 | =====
3 |
4 | .. automodule:: litestar.stores.redis
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/stores/registry.rst:
--------------------------------------------------------------------------------
1 | registry
2 | ========
3 |
4 | .. automodule:: litestar.stores.registry
5 | :members: StoreRegistry
6 |
--------------------------------------------------------------------------------
/docs/reference/stores/valkey.rst:
--------------------------------------------------------------------------------
1 | valkey
2 | ======
3 |
4 | .. automodule:: litestar.stores.valkey
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/template.rst:
--------------------------------------------------------------------------------
1 | template
2 | ========
3 |
4 | .. automodule:: litestar.template
5 | :members:
6 |
--------------------------------------------------------------------------------
/docs/reference/testing.rst:
--------------------------------------------------------------------------------
1 | testing
2 | =======
3 |
4 |
5 | .. automodule:: litestar.testing
6 | :members: RequestFactory, BaseTestClient, TestClient, AsyncTestClient, create_async_test_client, create_test_client, subprocess_sync_client, subprocess_async_client
7 | :undoc-members: WebSocketTestSession
8 |
9 |
10 |
11 | .. autoclass:: litestar.testing.life_span_handler.LifeSpanHandler
12 |
--------------------------------------------------------------------------------
/docs/reference/typing.rst:
--------------------------------------------------------------------------------
1 | typing
2 | ======
3 |
4 | .. py:currentmodule:: litestar.typing
5 |
6 | .. automodule:: litestar.typing
7 | :members:
8 |
--------------------------------------------------------------------------------
/docs/release-notes/index.rst:
--------------------------------------------------------------------------------
1 | :orphan:
2 |
3 | Release notes
4 | =============
5 |
6 | .. toctree::
7 | :titlesonly:
8 |
9 | whats-new-2
10 | 2.x Changelog
11 | 1.x Changelog
12 |
--------------------------------------------------------------------------------
/docs/topics/deployment/index.rst:
--------------------------------------------------------------------------------
1 | Deployment
2 | ==========
3 |
4 | This section contains articles about deploying Litestar applications
5 | to various platforms and environments; this includes deploying with
6 | ``systemd``, Docker, Kubernetes, serverless, and more.
7 |
8 | Contents
9 | --------
10 |
11 | .. toctree::
12 |
13 | nginx-unit
14 | manually-with-asgi-server
15 | docker
16 | supervisor
17 |
--------------------------------------------------------------------------------
/docs/topics/index.rst:
--------------------------------------------------------------------------------
1 | Topics
2 | ======
3 |
4 | Topics are a collection of articles about technical concepts, background information,
5 | design decisions and similar topics on a higher level.
6 |
7 | This includes things like the difference between synchronous and asynchronous, API design,
8 | deployment strategies, ASGI and WSGI, and so on.
9 |
10 | .. toctree::
11 | :titlesonly:
12 | :caption: Articles
13 |
14 | sync-vs-async
15 | deployment/index
16 |
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/dto_data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/dto_data.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/explicit_field_renaming.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/explicit_field_renaming.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/field_renaming_strategy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/field_renaming_strategy.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/initial_pattern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/initial_pattern.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/max_nested_depth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/max_nested_depth.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/nested_collection_exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/nested_collection_exclude.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/nested_exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/nested_exclude.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/patch_handlers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/patch_handlers.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/put_handlers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/put_handlers.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/read_only_fields_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/read_only_fields_error.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/simple_exclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/simple_exclude.png
--------------------------------------------------------------------------------
/docs/tutorials/dto-tutorial/images/simple_receive_data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/dto-tutorial/images/simple_receive_data.png
--------------------------------------------------------------------------------
/docs/tutorials/index.rst:
--------------------------------------------------------------------------------
1 | Tutorials
2 | =========
3 |
4 | .. toctree::
5 | :hidden:
6 |
7 | todo-app/index
8 | sqlalchemy/index
9 | dto-tutorial/index
10 | repository-tutorial/index
11 |
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/done-john-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/done-john-2.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/done-john.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/done-john.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/get_todo_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/get_todo_list.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/hello_world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/hello_world.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/missing-query.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/missing-query.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-dataclass-bad-body.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-dataclass-bad-body.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-dict-vs-dataclass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-dict-vs-dataclass.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-failed-validation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-failed-validation.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-get-example-request.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-get-example-request.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-get.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-get.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-post-dataclass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-post-dataclass.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-post-dict-response.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-post-dict-response.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/swagger-post-dict.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/swagger-post-dict.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/todos-done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/todos-done.png
--------------------------------------------------------------------------------
/docs/tutorials/todo-app/images/todos-not-done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/docs/tutorials/todo-app/images/todos-not-done.png
--------------------------------------------------------------------------------
/docs/usage/databases/index.rst:
--------------------------------------------------------------------------------
1 | Databases
2 | =========
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | sqlalchemy/index
8 | piccolo
9 |
--------------------------------------------------------------------------------
/docs/usage/databases/piccolo.rst:
--------------------------------------------------------------------------------
1 | Piccolo ORM
2 | ===========
3 |
4 | Piccolo ORM is an easy-to-use async ORM and query builder and Litestar includes
5 | the class :class:`PiccoloDTO `
6 | for data flow control. Example of a small application:
7 |
8 | .. literalinclude:: /examples/contrib/piccolo/app.py
9 | :caption: ``app.py``
10 | :language: python
11 |
--------------------------------------------------------------------------------
/docs/usage/databases/sqlalchemy/index.rst:
--------------------------------------------------------------------------------
1 | SQLAlchemy
2 | ----------
3 |
4 | .. toctree::
5 |
6 | models_and_repository
7 | plugins/index
8 |
--------------------------------------------------------------------------------
/docs/usage/index.rst:
--------------------------------------------------------------------------------
1 | Usage
2 | =====
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | applications
8 | routing/index
9 | requests
10 | caching
11 | channels
12 | cli
13 | databases/index
14 | debugging
15 | dependency-injection
16 | dto/index
17 | events
18 | exceptions
19 | htmx
20 | lifecycle-hooks
21 | logging
22 | metrics/index
23 | middleware/index
24 | openapi/index
25 | plugins/index
26 | responses
27 | security/index
28 | static-files
29 | custom-types
30 | stores
31 | templating
32 | testing
33 | websockets
34 |
--------------------------------------------------------------------------------
/docs/usage/metrics/index.rst:
--------------------------------------------------------------------------------
1 | Metrics
2 | =======
3 |
4 | .. toctree::
5 | :titlesonly:
6 |
7 | open-telemetry
8 | prometheus
9 |
--------------------------------------------------------------------------------
/docs/usage/routing/index.rst:
--------------------------------------------------------------------------------
1 | =======
2 | Routing
3 | =======
4 |
5 | Routing is a fundamental aspect of building web applications with Litestar.
6 | It involves mapping URLs to the appropriate request handlers that process and respond to client requests.
7 |
8 | Litestar provides a flexible and intuitive routing system that allows you to define routes at various
9 | layers of your application.
10 |
11 | .. toctree::
12 | :caption: Articles
13 |
14 | overview
15 | handlers
16 | parameters
17 |
--------------------------------------------------------------------------------
/docs/usage/security/index.rst:
--------------------------------------------------------------------------------
1 | Security
2 | ========
3 |
4 | While Litestar is agnostic to the security scheme used - allowing users to use any standard and non-standard security
5 | scheme they deem necessary, it does include several builtin components that allow for easy implementation of
6 | authentication and authorization.
7 |
8 | .. toctree::
9 | :titlesonly:
10 | :caption: Articles
11 |
12 | abstract-authentication-middleware
13 | security-backends
14 | guards
15 | excluding-and-including-endpoints
16 | jwt
17 | secret-datastructures
18 |
--------------------------------------------------------------------------------
/litestar/__main__.py:
--------------------------------------------------------------------------------
1 | from litestar.cli.main import litestar_group
2 |
3 |
4 | def run_cli() -> None:
5 | """Application Entrypoint."""
6 | litestar_group()
7 |
8 |
9 | if __name__ == "__main__":
10 | run_cli()
11 |
--------------------------------------------------------------------------------
/litestar/_asgi/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar._asgi.asgi_router import ASGIRouter
2 |
3 | __all__ = ("ASGIRouter",)
4 |
--------------------------------------------------------------------------------
/litestar/_asgi/routing_trie/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar._asgi.routing_trie.mapping import add_route_to_trie
2 | from litestar._asgi.routing_trie.traversal import parse_path_to_route
3 | from litestar._asgi.routing_trie.types import RouteTrieNode
4 | from litestar._asgi.routing_trie.validate import validate_node
5 |
6 | __all__ = ("RouteTrieNode", "add_route_to_trie", "parse_path_to_route", "validate_node")
7 |
--------------------------------------------------------------------------------
/litestar/_kwargs/__init__.py:
--------------------------------------------------------------------------------
1 | from .kwargs_model import KwargsModel
2 |
3 | __all__ = ("KwargsModel",)
4 |
--------------------------------------------------------------------------------
/litestar/_kwargs/types.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import Any, Awaitable, Callable, Dict
4 |
5 | from typing_extensions import TypeAlias
6 |
7 | from litestar.connection import ASGIConnection
8 |
9 | Extractor: TypeAlias = Callable[[Dict[str, Any], ASGIConnection], Awaitable[None]]
10 |
--------------------------------------------------------------------------------
/litestar/_layers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/_layers/__init__.py
--------------------------------------------------------------------------------
/litestar/_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/_openapi/__init__.py
--------------------------------------------------------------------------------
/litestar/_openapi/schema_generation/__init__.py:
--------------------------------------------------------------------------------
1 | from .plugins import openapi_schema_plugins
2 | from .schema import SchemaCreator
3 |
4 | __all__ = (
5 | "SchemaCreator",
6 | "openapi_schema_plugins",
7 | )
8 |
--------------------------------------------------------------------------------
/litestar/_openapi/typescript_converter/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/_openapi/typescript_converter/__init__.py
--------------------------------------------------------------------------------
/litestar/_signature/__init__.py:
--------------------------------------------------------------------------------
1 | from .model import SignatureModel
2 |
3 | __all__ = ("SignatureModel",)
4 |
--------------------------------------------------------------------------------
/litestar/_signature/types.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import Any
4 |
5 | from msgspec import ValidationError
6 |
7 |
8 | class ExtendedMsgSpecValidationError(ValidationError):
9 | def __init__(self, errors: list[dict[str, Any]]) -> None:
10 | self.errors = errors
11 | super().__init__(errors)
12 |
--------------------------------------------------------------------------------
/litestar/channels/__init__.py:
--------------------------------------------------------------------------------
1 | from .backends.base import ChannelsBackend
2 | from .plugin import ChannelsPlugin
3 | from .subscriber import Subscriber
4 |
5 | __all__ = ("ChannelsBackend", "ChannelsPlugin", "Subscriber")
6 |
--------------------------------------------------------------------------------
/litestar/channels/backends/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/channels/backends/__init__.py
--------------------------------------------------------------------------------
/litestar/channels/backends/_redis_flushall_streams.lua:
--------------------------------------------------------------------------------
1 | local key_pattern = ARGV[1]
2 |
3 | local cursor = 0
4 | local deleted_streams = 0
5 |
6 | repeat
7 | local result = redis.call('SCAN', cursor, 'MATCH', key_pattern)
8 | for _,key in ipairs(result[2]) do
9 | redis.call('DEL', key)
10 | deleted_streams = deleted_streams + 1
11 | end
12 | cursor = tonumber(result[1])
13 | until cursor == 0
14 |
15 | return deleted_streams
16 |
--------------------------------------------------------------------------------
/litestar/channels/backends/_redis_pubsub_publish.lua:
--------------------------------------------------------------------------------
1 | local data = ARGV[1]
2 |
3 | for _, channel in ipairs(KEYS) do
4 | redis.call("PUBLISH", channel, data)
5 | end
6 |
--------------------------------------------------------------------------------
/litestar/channels/backends/_redis_xadd_expire.lua:
--------------------------------------------------------------------------------
1 | local data = ARGV[1]
2 | local limit = ARGV[2]
3 | local exp = ARGV[3]
4 | local maxlen_approx = ARGV[4]
5 |
6 | for i, key in ipairs(KEYS) do
7 | if maxlen_approx == 1 then
8 | redis.call("XADD", key, "MAXLEN", "~", limit, "*", "data", data, "channel", ARGV[i + 4])
9 | else
10 | redis.call("XADD", key, "MAXLEN", limit, "*", "data", data, "channel", ARGV[i + 4])
11 | end
12 | redis.call("PEXPIRE", key, exp)
13 | end
14 |
--------------------------------------------------------------------------------
/litestar/cli/commands/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/cli/commands/__init__.py
--------------------------------------------------------------------------------
/litestar/config/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/config/__init__.py
--------------------------------------------------------------------------------
/litestar/contrib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/contrib/__init__.py
--------------------------------------------------------------------------------
/litestar/contrib/htmx/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/contrib/htmx/__init__.py
--------------------------------------------------------------------------------
/litestar/contrib/jwt/jwt_auth.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.security.jwt.auth import BaseJWTAuth, JWTAuth, JWTCookieAuth, OAuth2Login, OAuth2PasswordBearerAuth
4 |
5 | __all__ = ("BaseJWTAuth", "JWTAuth", "JWTCookieAuth", "OAuth2Login", "OAuth2PasswordBearerAuth")
6 |
--------------------------------------------------------------------------------
/litestar/contrib/jwt/jwt_token.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.security.jwt.token import Token
4 |
5 | __all__ = ("Token",)
6 |
--------------------------------------------------------------------------------
/litestar/contrib/jwt/middleware.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.security.jwt.middleware import JWTAuthenticationMiddleware, JWTCookieAuthenticationMiddleware
4 |
5 | __all__ = ("JWTAuthenticationMiddleware", "JWTCookieAuthenticationMiddleware")
6 |
--------------------------------------------------------------------------------
/litestar/contrib/minijnja.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import Any
4 |
5 | from litestar.utils.deprecation import warn_deprecation
6 |
7 | from . import minijinja as _minijinja
8 |
9 |
10 | def __getattr__(name: str) -> Any:
11 | warn_deprecation(
12 | "2.3.0",
13 | "contrib.minijnja",
14 | "import",
15 | removal_in="3.0.0",
16 | alternative="contrib.minijinja",
17 | )
18 | return getattr(_minijinja, name)
19 |
--------------------------------------------------------------------------------
/litestar/contrib/opentelemetry/__init__.py:
--------------------------------------------------------------------------------
1 | from .config import OpenTelemetryConfig
2 | from .middleware import OpenTelemetryInstrumentationMiddleware
3 | from .plugin import OpenTelemetryPlugin
4 |
5 | __all__ = (
6 | "OpenTelemetryConfig",
7 | "OpenTelemetryInstrumentationMiddleware",
8 | "OpenTelemetryPlugin",
9 | )
10 |
--------------------------------------------------------------------------------
/litestar/contrib/pydantic/config.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/contrib/pydantic/config.py
--------------------------------------------------------------------------------
/litestar/dto/__init__.py:
--------------------------------------------------------------------------------
1 | from .base_dto import AbstractDTO
2 | from .config import DTOConfig
3 | from .data_structures import DTOData, DTOFieldDefinition
4 | from .dataclass_dto import DataclassDTO
5 | from .field import DTOField, Mark, dto_field
6 | from .msgspec_dto import MsgspecDTO
7 | from .types import RenameStrategy
8 |
9 | __all__ = (
10 | "AbstractDTO",
11 | "DTOConfig",
12 | "DTOData",
13 | "DTOField",
14 | "DTOFieldDefinition",
15 | "DataclassDTO",
16 | "Mark",
17 | "MsgspecDTO",
18 | "RenameStrategy",
19 | "dto_field",
20 | )
21 |
--------------------------------------------------------------------------------
/litestar/dto/types.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import TYPE_CHECKING
4 |
5 | if TYPE_CHECKING:
6 | from typing import Callable, Literal
7 |
8 | from typing_extensions import TypeAlias
9 |
10 | __all__ = ("RenameStrategy",)
11 |
12 | RenameStrategy: TypeAlias = 'Literal["lower", "upper", "camel", "pascal", "kebab"] | Callable[[str], str]'
13 | """A pre-defined strategy or a custom callback for converting DTO field names."""
14 |
--------------------------------------------------------------------------------
/litestar/events/__init__.py:
--------------------------------------------------------------------------------
1 | from .emitter import BaseEventEmitterBackend, SimpleEventEmitter
2 | from .listener import EventListener, listener
3 |
4 | __all__ = ("BaseEventEmitterBackend", "EventListener", "SimpleEventEmitter", "listener")
5 |
--------------------------------------------------------------------------------
/litestar/exceptions/dto_exceptions.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.exceptions import LitestarException
4 |
5 | __all__ = ("DTOFactoryException", "InvalidAnnotationException")
6 |
7 |
8 | class DTOFactoryException(LitestarException):
9 | """Base DTO exception type."""
10 |
11 |
12 | class InvalidAnnotationException(DTOFactoryException):
13 | """Unexpected DTO type argument."""
14 |
--------------------------------------------------------------------------------
/litestar/exceptions/responses/templates/body.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 | Litestar exception page
10 |
11 |
12 | {error}
13 | {error_description}
14 | {exception_data}
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/litestar/exceptions/responses/templates/frame.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | ▼
4 | {file} in {symbol_name} at line
5 | {line}
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/litestar/handlers/http_handlers/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from .base import HTTPRouteHandler, route
4 | from .decorators import delete, get, head, patch, post, put
5 |
6 | __all__ = (
7 | "HTTPRouteHandler",
8 | "delete",
9 | "get",
10 | "head",
11 | "patch",
12 | "post",
13 | "put",
14 | "route",
15 | )
16 |
--------------------------------------------------------------------------------
/litestar/logging/__init__.py:
--------------------------------------------------------------------------------
1 | from .config import BaseLoggingConfig, LoggingConfig, StructLoggingConfig
2 |
3 | __all__ = ("BaseLoggingConfig", "LoggingConfig", "StructLoggingConfig")
4 |
--------------------------------------------------------------------------------
/litestar/middleware/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.middleware.authentication import (
2 | AbstractAuthenticationMiddleware,
3 | AuthenticationResult,
4 | )
5 | from litestar.middleware.base import (
6 | AbstractMiddleware,
7 | ASGIMiddleware,
8 | DefineMiddleware,
9 | MiddlewareProtocol,
10 | )
11 |
12 | __all__ = (
13 | "ASGIMiddleware",
14 | "AbstractAuthenticationMiddleware",
15 | "AbstractMiddleware",
16 | "AuthenticationResult",
17 | "DefineMiddleware",
18 | "MiddlewareProtocol",
19 | )
20 |
--------------------------------------------------------------------------------
/litestar/middleware/_internal/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/middleware/_internal/__init__.py
--------------------------------------------------------------------------------
/litestar/middleware/_internal/exceptions/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.middleware._internal.exceptions.middleware import ExceptionHandlerMiddleware
2 |
3 | __all__ = ("ExceptionHandlerMiddleware",)
4 |
--------------------------------------------------------------------------------
/litestar/middleware/compression/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.middleware.compression.facade import CompressionFacade
2 | from litestar.middleware.compression.middleware import CompressionMiddleware
3 |
4 | __all__ = ("CompressionFacade", "CompressionMiddleware")
5 |
--------------------------------------------------------------------------------
/litestar/middleware/session/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import SessionMiddleware
2 |
3 | __all__ = ("SessionMiddleware",)
4 |
--------------------------------------------------------------------------------
/litestar/openapi/__init__.py:
--------------------------------------------------------------------------------
1 | from .config import OpenAPIConfig
2 | from .controller import OpenAPIController
3 | from .datastructures import ResponseSpec
4 |
5 | __all__ = ("OpenAPIConfig", "OpenAPIController", "ResponseSpec")
6 |
--------------------------------------------------------------------------------
/litestar/plugins/core/__init__.py:
--------------------------------------------------------------------------------
1 | from ._msgspec import MsgspecDIPlugin
2 |
3 | __all__ = ("MsgspecDIPlugin",)
4 |
--------------------------------------------------------------------------------
/litestar/plugins/prometheus/__init__.py:
--------------------------------------------------------------------------------
1 | from .config import PrometheusConfig
2 | from .controller import PrometheusController
3 | from .middleware import PrometheusMiddleware
4 |
5 | __all__ = ("PrometheusConfig", "PrometheusController", "PrometheusMiddleware")
6 |
--------------------------------------------------------------------------------
/litestar/plugins/pydantic/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/plugins/pydantic/plugins/__init__.py
--------------------------------------------------------------------------------
/litestar/py.typed:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/py.typed
--------------------------------------------------------------------------------
/litestar/repository/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from .abc import AbstractAsyncRepository, AbstractSyncRepository
4 | from .exceptions import ConflictError, NotFoundError, RepositoryError
5 | from .filters import FilterTypes
6 |
7 | __all__ = (
8 | "AbstractAsyncRepository",
9 | "AbstractSyncRepository",
10 | "ConflictError",
11 | "FilterTypes",
12 | "NotFoundError",
13 | "RepositoryError",
14 | )
15 |
--------------------------------------------------------------------------------
/litestar/repository/_exceptions.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations # pragma: no cover
2 |
3 | __all__ = ("ConflictError", "NotFoundError", "RepositoryError") # pragma: no cover
4 |
5 |
6 | class RepositoryError(Exception): # pragma: no cover
7 | """Base repository exception type."""
8 |
9 |
10 | class ConflictError(RepositoryError): # pragma: no cover
11 | """Data integrity error."""
12 |
13 |
14 | class NotFoundError(RepositoryError): # pragma: no cover
15 | """An identity does not exist."""
16 |
--------------------------------------------------------------------------------
/litestar/repository/abc/__init__.py:
--------------------------------------------------------------------------------
1 | from ._async import AbstractAsyncRepository
2 | from ._sync import AbstractSyncRepository
3 |
4 | __all__ = (
5 | "AbstractAsyncRepository",
6 | "AbstractSyncRepository",
7 | )
8 |
--------------------------------------------------------------------------------
/litestar/repository/exceptions.py:
--------------------------------------------------------------------------------
1 | try:
2 | from advanced_alchemy.exceptions import IntegrityError as ConflictError
3 | from advanced_alchemy.exceptions import NotFoundError, RepositoryError
4 | except ImportError: # pragma: no cover
5 | from ._exceptions import ConflictError, NotFoundError, RepositoryError # type: ignore[assignment]
6 |
7 | __all__ = ("ConflictError", "NotFoundError", "RepositoryError")
8 |
--------------------------------------------------------------------------------
/litestar/repository/testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/repository/testing/__init__.py
--------------------------------------------------------------------------------
/litestar/response/__init__.py:
--------------------------------------------------------------------------------
1 | from .base import Response
2 | from .file import File
3 | from .redirect import Redirect
4 | from .sse import ServerSentEvent, ServerSentEventMessage
5 | from .streaming import Stream
6 | from .template import Template
7 |
8 | __all__ = (
9 | "File",
10 | "Redirect",
11 | "Response",
12 | "ServerSentEvent",
13 | "ServerSentEventMessage",
14 | "Stream",
15 | "Template",
16 | )
17 |
--------------------------------------------------------------------------------
/litestar/routes/__init__.py:
--------------------------------------------------------------------------------
1 | from .asgi import ASGIRoute
2 | from .base import BaseRoute
3 | from .http import HTTPRoute
4 | from .websocket import WebSocketRoute
5 |
6 | __all__ = ("ASGIRoute", "BaseRoute", "HTTPRoute", "WebSocketRoute")
7 |
--------------------------------------------------------------------------------
/litestar/security/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.security.base import AbstractSecurityConfig
2 |
3 | __all__ = ("AbstractSecurityConfig",)
4 |
--------------------------------------------------------------------------------
/litestar/security/jwt/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.security.jwt.auth import (
2 | BaseJWTAuth,
3 | JWTAuth,
4 | JWTCookieAuth,
5 | OAuth2Login,
6 | OAuth2PasswordBearerAuth,
7 | )
8 | from litestar.security.jwt.middleware import (
9 | JWTAuthenticationMiddleware,
10 | JWTCookieAuthenticationMiddleware,
11 | )
12 | from litestar.security.jwt.token import Token
13 |
14 | __all__ = (
15 | "BaseJWTAuth",
16 | "JWTAuth",
17 | "JWTAuthenticationMiddleware",
18 | "JWTCookieAuth",
19 | "JWTCookieAuthenticationMiddleware",
20 | "OAuth2Login",
21 | "OAuth2PasswordBearerAuth",
22 | "Token",
23 | )
24 |
--------------------------------------------------------------------------------
/litestar/security/session_auth/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.security.session_auth.auth import SessionAuth
2 | from litestar.security.session_auth.middleware import SessionAuthMiddleware
3 |
4 | __all__ = ("SessionAuth", "SessionAuthMiddleware")
5 |
--------------------------------------------------------------------------------
/litestar/serialization/__init__.py:
--------------------------------------------------------------------------------
1 | from .msgspec_hooks import (
2 | decode_json,
3 | decode_msgpack,
4 | default_deserializer,
5 | default_serializer,
6 | encode_json,
7 | encode_msgpack,
8 | get_serializer,
9 | )
10 |
11 | __all__ = (
12 | "decode_json",
13 | "decode_msgpack",
14 | "default_deserializer",
15 | "default_serializer",
16 | "encode_json",
17 | "encode_msgpack",
18 | "get_serializer",
19 | )
20 |
--------------------------------------------------------------------------------
/litestar/static_files/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.static_files.base import StaticFiles
2 | from litestar.static_files.config import StaticFilesConfig, create_static_files_router
3 |
4 | __all__ = ("StaticFiles", "StaticFilesConfig", "create_static_files_router")
5 |
--------------------------------------------------------------------------------
/litestar/stores/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/litestar/stores/__init__.py
--------------------------------------------------------------------------------
/litestar/template/__init__.py:
--------------------------------------------------------------------------------
1 | from litestar.template.base import TemplateEngineProtocol, TemplateProtocol
2 | from litestar.template.config import TemplateConfig
3 |
4 | __all__ = ("TemplateConfig", "TemplateEngineProtocol", "TemplateProtocol")
5 |
--------------------------------------------------------------------------------
/litestar/types/debugger_types.py:
--------------------------------------------------------------------------------
1 | from types import ModuleType, TracebackType
2 | from typing import Any, Optional, Protocol, Union
3 |
4 | from typing_extensions import TypeAlias
5 |
6 |
7 | class PDBProtocol(Protocol):
8 | @staticmethod
9 | def post_mortem(
10 | traceback: Optional[TracebackType] = None,
11 | *args: Any,
12 | **kwargs: Any,
13 | ) -> Any: ...
14 |
15 |
16 | Debugger: TypeAlias = Union[ModuleType, PDBProtocol]
17 |
--------------------------------------------------------------------------------
/litestar/types/empty.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | __all__ = ("Empty", "EmptyType")
4 |
5 | from enum import Enum
6 | from typing import Final, Literal
7 |
8 |
9 | class _EmptyEnum(Enum):
10 | """A sentinel enum used as placeholder."""
11 |
12 | EMPTY = 0
13 |
14 |
15 | EmptyType = Literal[_EmptyEnum.EMPTY]
16 | Empty: Final = _EmptyEnum.EMPTY
17 |
--------------------------------------------------------------------------------
/test_apps/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/__init__.py
--------------------------------------------------------------------------------
/test_apps/asgi_with_starlette_test_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/asgi_with_starlette_test_app/__init__.py
--------------------------------------------------------------------------------
/test_apps/debugging/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/debugging/__init__.py
--------------------------------------------------------------------------------
/test_apps/logging_test_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/logging_test_app/__init__.py
--------------------------------------------------------------------------------
/test_apps/logging_test_app/main.py:
--------------------------------------------------------------------------------
1 | from litestar import Litestar, get
2 | from litestar.logging.config import LoggingConfig
3 | from litestar.middleware.logging import LoggingMiddlewareConfig
4 |
5 |
6 | @get("/")
7 | async def handler() -> dict[str, str]:
8 | return {"hello": "world"}
9 |
10 |
11 | logging_middleware_config = LoggingMiddlewareConfig()
12 |
13 | app = Litestar(
14 | route_handlers=[handler],
15 | logging_config=LoggingConfig(),
16 | middleware=[logging_middleware_config.middleware],
17 | )
18 |
19 |
20 | if __name__ == "__main__":
21 | import uvicorn
22 |
23 | uvicorn.run(app)
24 |
--------------------------------------------------------------------------------
/test_apps/openapi_test_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/openapi_test_app/__init__.py
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/piccolo_admin_test_app/__init__.py
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/piccolo_admin_test_app/home/__init__.py
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/piccolo_app.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from piccolo.conf.apps import AppConfig, table_finder
4 |
5 | CURRENT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
6 |
7 |
8 | APP_CONFIG = AppConfig(
9 | app_name="home",
10 | migrations_folder_path=os.path.join(CURRENT_DIRECTORY, "piccolo_migrations"),
11 | table_classes=table_finder(modules=["home.tables"], exclude_imported=True),
12 | migration_dependencies=[],
13 | commands=[],
14 | )
15 |
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/piccolo_migrations/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/piccolo_admin_test_app/home/piccolo_migrations/.gitkeep
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/schema.py:
--------------------------------------------------------------------------------
1 | from piccolo.utils.pydantic import create_pydantic_model
2 |
3 | from test_apps.piccolo_admin_test_app.home.tables import Task
4 |
5 | # task models
6 | TaskModelIn = create_pydantic_model(table=Task, model_name="TaskModelIn")
7 | TaskModelOut = create_pydantic_model(
8 | table=Task,
9 | include_default_columns=True,
10 | model_name="TaskModelOut",
11 | )
12 |
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/tables.py:
--------------------------------------------------------------------------------
1 | from piccolo.apps.user.tables import BaseUser
2 | from piccolo.columns import Boolean, ForeignKey, Timestamp, Varchar
3 | from piccolo.columns.readable import Readable
4 | from piccolo.table import Table
5 | from piccolo_conf import DB
6 |
7 |
8 | class Task(Table, db=DB):
9 | """An example table."""
10 |
11 | name = Varchar()
12 | completed = Boolean()
13 | created_at = Timestamp()
14 | task_user = ForeignKey(BaseUser)
15 |
16 | @classmethod
17 | def get_readable(cls) -> Readable:
18 | return Readable(template="%s", columns=[cls.task_user.username])
19 |
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/home/templates/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/piccolo_admin_test_app/home/templates/.gitkeep
--------------------------------------------------------------------------------
/test_apps/piccolo_admin_test_app/piccolo_conf.py:
--------------------------------------------------------------------------------
1 | from piccolo.engine import SQLiteEngine
2 |
3 | DB = SQLiteEngine(path="test.sqlite")
4 |
--------------------------------------------------------------------------------
/test_apps/sse/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/sse/__init__.py
--------------------------------------------------------------------------------
/test_apps/static_files_test_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/static_files_test_app/__init__.py
--------------------------------------------------------------------------------
/test_apps/static_files_test_app/main.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 |
3 | from litestar import Litestar, get
4 | from litestar.static_files.config import StaticFilesConfig
5 |
6 |
7 | @get("/")
8 | async def handler() -> dict[str, str]:
9 | return {"hello": "world"}
10 |
11 |
12 | app = Litestar(
13 | route_handlers=[],
14 | static_files_config=[
15 | StaticFilesConfig(directories=[Path(__file__).parent / "public"], path="/", html_mode=True),
16 | ],
17 | )
18 |
19 |
20 | if __name__ == "__main__":
21 | import uvicorn
22 |
23 | uvicorn.run(app)
24 |
--------------------------------------------------------------------------------
/test_apps/static_files_test_app/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World!
5 |
6 |
7 |
--------------------------------------------------------------------------------
/test_apps/structlog_app/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/test_apps/structlog_app/__init__.py
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/__init__.py
--------------------------------------------------------------------------------
/tests/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3"
2 |
3 | services:
4 | postgres:
5 | image: postgres:latest
6 | ports:
7 | - "5423:5432" # use a non-standard port here
8 | environment:
9 | POSTGRES_PASSWORD: super-secret
10 | redis:
11 | image: redis:latest
12 | restart: always
13 | ports:
14 | - "6397:6379" # use a non-standard port here
15 | valkey:
16 | image: valkey/valkey:latest
17 | restart: always
18 | ports:
19 | - "6381:6379" # also a non-standard port
20 |
--------------------------------------------------------------------------------
/tests/e2e/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_cors/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_cors/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_dependency_injection/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_dependency_injection/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_exception_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_exception_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_life_cycle_hooks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_life_cycle_hooks/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_logging/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_logging/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_middleware/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_middleware/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_openapi/__init__.py
--------------------------------------------------------------------------------
/tests/e2e/test_routing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/e2e/test_routing/__init__.py
--------------------------------------------------------------------------------
/tests/examples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/__init__.py
--------------------------------------------------------------------------------
/tests/examples/conftest.py:
--------------------------------------------------------------------------------
1 | import logging
2 | from typing import Generator
3 |
4 | import pytest
5 |
6 |
7 | @pytest.fixture(autouse=True)
8 | def disable_httpx_logging() -> Generator[None, None, None]:
9 | # ensure that httpx logging is not interfering with our test client
10 | httpx_logger = logging.getLogger("httpx")
11 | initial_level = httpx_logger.level
12 | httpx_logger.setLevel(logging.WARNING)
13 | yield
14 | httpx_logger.setLevel(initial_level)
15 |
--------------------------------------------------------------------------------
/tests/examples/test_application_hooks/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_application_hooks/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_application_hooks/test_application_before_send.py:
--------------------------------------------------------------------------------
1 | from docs.examples.application_hooks import before_send_hook
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_application_before_send_hooks() -> None:
8 | with TestClient(app=before_send_hook.app) as client:
9 | response = client.get("/test")
10 | assert response.status_code == HTTP_200_OK
11 | assert response.headers.get("My Header") == "value injected during send"
12 |
--------------------------------------------------------------------------------
/tests/examples/test_application_hooks/test_on_app_init.py:
--------------------------------------------------------------------------------
1 | from docs.examples.application_hooks.on_app_init import app, close_db_connection
2 |
3 |
4 | def test_on_app_init() -> None:
5 | assert close_db_connection in app.on_shutdown
6 |
--------------------------------------------------------------------------------
/tests/examples/test_application_state/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_application_state/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_application_state/test_passing_initial_state.py:
--------------------------------------------------------------------------------
1 | from docs.examples.application_state.passing_initial_state import app
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_passing_initial_state_example() -> None:
8 | with TestClient(app) as client:
9 | response = client.get("/")
10 | assert response.status_code == HTTP_200_OK
11 | assert response.json() == {"count": 100}
12 |
--------------------------------------------------------------------------------
/tests/examples/test_application_state/test_using_custom_state.py:
--------------------------------------------------------------------------------
1 | from docs.examples.application_state.using_custom_state import app
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_using_custom_state_example() -> None:
8 | with TestClient(app) as client:
9 | response = client.get("/")
10 | assert response.status_code == HTTP_200_OK
11 | assert response.json() == {"count": 1}
12 |
--------------------------------------------------------------------------------
/tests/examples/test_application_state/test_using_immutable_state.py:
--------------------------------------------------------------------------------
1 | from docs.examples.application_state.using_immutable_state import app
2 |
3 | from litestar.status_codes import HTTP_500_INTERNAL_SERVER_ERROR
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_using_custom_state_example() -> None:
8 | with TestClient(app) as client:
9 | response = client.get("/")
10 | assert response.status_code == HTTP_500_INTERNAL_SERVER_ERROR
11 |
--------------------------------------------------------------------------------
/tests/examples/test_contrib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_contrib/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_contrib/prometheus/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_contrib/prometheus/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_contrib/test_sqlalchemy/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_contrib/test_sqlalchemy/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_contrib/test_sqlalchemy/plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_contrib/test_sqlalchemy/plugins/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_data_transfer_objects/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/conftest.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import pytest
4 |
5 |
6 | @pytest.fixture
7 | def user_data() -> dict:
8 | return {"name": "Mr Sunglass", "email": "mr.sunglass@example.com", "age": 30}
9 |
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_factory/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_data_transfer_objects/test_factory/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_factory/test_dto_data_usage.py:
--------------------------------------------------------------------------------
1 | from unittest.mock import ANY
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_create_user(user_data) -> None:
7 | from docs.examples.data_transfer_objects.factory.dto_data_usage import app
8 |
9 | with TestClient(app) as client:
10 | response = client.post("/users", json=user_data)
11 |
12 | assert response.status_code == 201
13 | assert response.json() == {"id": ANY, "name": "Mr Sunglass", "email": "mr.sunglass@example.com", "age": 30}
14 |
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_factory/test_leading_underscore_private.py:
--------------------------------------------------------------------------------
1 | from litestar.status_codes import HTTP_201_CREATED
2 | from litestar.testing.client import TestClient
3 |
4 |
5 | def test_create_underscored_value() -> None:
6 | from docs.examples.data_transfer_objects.factory.leading_underscore_private import app
7 |
8 | with TestClient(app=app) as client:
9 | response = client.post("/", json={"this_will": "stay", "_this_will": "go_away!"})
10 |
11 | assert response.status_code == HTTP_201_CREATED
12 | assert response.json() == {"this_will": "stay"}
13 |
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_factory/test_leading_underscore_private_override.py:
--------------------------------------------------------------------------------
1 | from litestar.status_codes import HTTP_201_CREATED
2 | from litestar.testing.client import TestClient
3 |
4 |
5 | def test_create_underscored_field() -> None:
6 | from docs.examples.data_transfer_objects.factory.leading_underscore_private_override import app
7 |
8 | with TestClient(app=app) as client:
9 | response = client.post("/", json={"this_will": "stay", "_this_will": "not_go_away!"})
10 |
11 | assert response.status_code == HTTP_201_CREATED
12 | assert response.json() == {"this_will": "stay", "_this_will": "not_go_away!"}
13 |
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_factory/test_type_checking.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 | from litestar.exceptions.dto_exceptions import InvalidAnnotationException
4 |
5 |
6 | def test_should_raise_error_on_route_registration() -> None:
7 | with pytest.raises(InvalidAnnotationException):
8 | from docs.examples.data_transfer_objects.factory.type_checking import app # noqa: F401
9 |
--------------------------------------------------------------------------------
/tests/examples/test_data_transfer_objects/test_overriding_implicit_return_dto.py:
--------------------------------------------------------------------------------
1 | from litestar.status_codes import HTTP_201_CREATED
2 | from litestar.testing.client import TestClient
3 |
4 |
5 | def test_create_user(user_data: dict) -> None:
6 | from docs.examples.data_transfer_objects.overriding_implicit_return_dto import app
7 |
8 | with TestClient(app=app) as client:
9 | response = client.post("/", json=user_data)
10 |
11 | assert response.status_code == HTTP_201_CREATED
12 | assert response.content == b"Mr Sunglass"
13 |
--------------------------------------------------------------------------------
/tests/examples/test_datastructures/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_datastructures/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_dependency_injection/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/test_dependency_default_value_no_dependency_fn.py:
--------------------------------------------------------------------------------
1 | from docs.examples.dependency_injection import dependency_with_default
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_optional_dependency_in_openapi_schema() -> None:
8 | with TestClient(app=dependency_with_default.app) as client:
9 | r = client.get("/schema/openapi.json")
10 | assert r.status_code == HTTP_200_OK
11 | assert r.json()["paths"]["/"]["get"]["parameters"][0]["name"] == "optional_dependency"
12 |
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/test_dependency_default_value_with_dependency_fn.py:
--------------------------------------------------------------------------------
1 | from docs.examples.dependency_injection import dependency_with_dependency_fn_and_default
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_optional_dependency_not_in_openapi_schema() -> None:
8 | with TestClient(app=dependency_with_dependency_fn_and_default.app) as client:
9 | r = client.get("/schema/openapi.json")
10 | assert r.status_code == HTTP_200_OK
11 | assert r.json()["paths"]["/"]["get"].get("parameters") is None
12 |
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/test_dependency_skip_validation.py:
--------------------------------------------------------------------------------
1 | from docs.examples.dependency_injection import dependency_skip_validation
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_route_skips_validation() -> None:
8 | with TestClient(app=dependency_skip_validation.app) as client:
9 | r = client.get("/")
10 | assert r.status_code == HTTP_200_OK
11 |
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/test_dependency_validation_error.py:
--------------------------------------------------------------------------------
1 | from docs.examples.dependency_injection import dependency_validation_error
2 |
3 | from litestar.status_codes import HTTP_500_INTERNAL_SERVER_ERROR
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_route_returns_internal_server_error() -> None:
8 | with TestClient(app=dependency_validation_error.app) as client:
9 | r = client.get("/")
10 | assert r.status_code == HTTP_500_INTERNAL_SERVER_ERROR
11 |
--------------------------------------------------------------------------------
/tests/examples/test_dependency_injection/tests_dependency_non_optional_not_provided.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | from docs.examples.dependency_injection import dependency_non_optional_not_provided
3 |
4 | from litestar import Litestar
5 | from litestar.exceptions import ImproperlyConfiguredException
6 |
7 |
8 | def test_route_returns_internal_server_error() -> None:
9 | with pytest.raises(ImproperlyConfiguredException):
10 | Litestar(route_handlers=[dependency_non_optional_not_provided.hello_world])
11 |
--------------------------------------------------------------------------------
/tests/examples/test_dto/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_dto/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_encoding_decoding/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_encoding_decoding/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_encoding_decoding/test_custom_type_encoding_decoding.py:
--------------------------------------------------------------------------------
1 | from docs.examples.encoding_decoding.custom_type_encoding_decoding import app
2 |
3 | from litestar.status_codes import HTTP_201_CREATED
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_custom_type_encoding_decoding_works() -> None:
8 | with TestClient(app) as client:
9 | response = client.post(
10 | "/asset",
11 | json={
12 | "user": "TenantA_Somebody",
13 | "name": "Some Asset",
14 | },
15 | )
16 |
17 | assert response.status_code == HTTP_201_CREATED
18 |
--------------------------------------------------------------------------------
/tests/examples/test_encoding_decoding/test_custom_type_pydantic.py:
--------------------------------------------------------------------------------
1 | from docs.examples.encoding_decoding.custom_type_pydantic import app
2 |
3 | from litestar.status_codes import HTTP_201_CREATED
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_custom_type_encoding_decoding_works() -> None:
8 | with TestClient(app) as client:
9 | response = client.post(
10 | "/asset",
11 | json={
12 | "user": "TenantA_Somebody",
13 | "name": "Some Asset",
14 | },
15 | )
16 |
17 | assert response.status_code == HTTP_201_CREATED
18 |
--------------------------------------------------------------------------------
/tests/examples/test_hello_world.py:
--------------------------------------------------------------------------------
1 | from docs.examples import hello_world
2 |
3 | from litestar.status_codes import HTTP_200_OK
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_hello_world_example() -> None:
8 | with TestClient(app=hello_world.app) as client:
9 | r = client.get("/")
10 | assert r.status_code == HTTP_200_OK
11 | assert r.json() == {"hello": "world"}
12 |
--------------------------------------------------------------------------------
/tests/examples/test_middleware/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_middleware/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_middleware/test_call_order.py:
--------------------------------------------------------------------------------
1 | from docs.examples.middleware.call_order import app
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_call_order() -> None:
7 | with TestClient(app=app) as client:
8 | response = client.get("/router/controller/handler")
9 | assert response.status_code == 200
10 | assert response.json() == [0, 1, 2, 3, 4, 5, 6, 7]
11 |
--------------------------------------------------------------------------------
/tests/examples/test_middleware/test_rate_limit_middleware.py:
--------------------------------------------------------------------------------
1 | from docs.examples.middleware.rate_limit import app
2 |
3 | from litestar.status_codes import HTTP_200_OK, HTTP_429_TOO_MANY_REQUESTS
4 | from litestar.testing import TestClient
5 |
6 |
7 | def test_rate_limit_middleware_example() -> None:
8 | with TestClient(app=app) as client:
9 | response = client.get("/")
10 | assert response.status_code == HTTP_200_OK
11 | assert response.text == "ok"
12 |
13 | response = client.get("/")
14 | assert response.status_code == HTTP_429_TOO_MANY_REQUESTS
15 |
--------------------------------------------------------------------------------
/tests/examples/test_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_openapi/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_pagination/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_pagination/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_parameters/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_parameters/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_plugins/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_plugins/test_di_plugin.py:
--------------------------------------------------------------------------------
1 | from docs.examples.plugins.di_plugin import app
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_di_plugin_example() -> None:
7 | with TestClient(app) as client:
8 | res = client.get("/?param=hello")
9 | assert res.status_code == 200
10 | assert res.text == "hello"
11 |
--------------------------------------------------------------------------------
/tests/examples/test_plugins/test_example_apps.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_dto_data_problem_statement_app() -> None:
7 | from docs.examples.plugins.init_plugin_protocol import app
8 |
9 | with TestClient(app) as client:
10 | assert client.get("/").json() == {"hello": "world"}
11 |
--------------------------------------------------------------------------------
/tests/examples/test_responses/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_responses/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_responses/test_custom_responses.py:
--------------------------------------------------------------------------------
1 | from docs.examples.responses.custom_responses import app as app_1
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_custom_responses() -> None:
7 | with TestClient(app=app_1) as client:
8 | res = client.get("/")
9 | assert res.status_code == 200
10 | assert res.json() == {"foo": ["bar", "baz"]}
11 |
--------------------------------------------------------------------------------
/tests/examples/test_responses/test_json_suffix_responses.py:
--------------------------------------------------------------------------------
1 | from docs.examples.responses.json_suffix_responses import app
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_json_suffix_responses() -> None:
7 | with TestClient(app=app) as client:
8 | res = client.get("/resources")
9 | assert res.status_code == 418
10 | assert res.json() == {
11 | "title": "Server thinks it is a teapot",
12 | "type": "Server delusion",
13 | "status": 418,
14 | }
15 | assert res.headers["content-type"] == "application/vnd.example.resource+json"
16 |
--------------------------------------------------------------------------------
/tests/examples/test_responses/test_returning_responses.py:
--------------------------------------------------------------------------------
1 | from docs.examples.responses.returning_responses import app
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_returning_responses() -> None:
7 | with TestClient(app=app) as client:
8 | res = client.get("/resources")
9 | assert res.headers["MY-HEADER"] == "xyz"
10 | assert res.cookies["my-cookie"] == "abc"
11 | assert res.json() == {"id": 1, "name": "my resource"}
12 |
--------------------------------------------------------------------------------
/tests/examples/test_responses/test_sse_responses.py:
--------------------------------------------------------------------------------
1 | from docs.examples.responses.sse_responses import app
2 | from httpx_sse import aconnect_sse
3 |
4 | from litestar.testing import AsyncTestClient
5 |
6 |
7 | async def test_sse_responses_example() -> None:
8 | async with AsyncTestClient(app=app) as client:
9 | async with aconnect_sse(client, "GET", f"{client.base_url}/count") as event_source:
10 | events = [sse async for sse in event_source.aiter_sse()]
11 | assert len(events) == 50
12 |
--------------------------------------------------------------------------------
/tests/examples/test_security/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_security/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_security/test_jwt/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_security/test_jwt/__init__.py
--------------------------------------------------------------------------------
/tests/examples/test_signature_namespace.py:
--------------------------------------------------------------------------------
1 | from docs.examples.signature_namespace.app import app
2 |
3 | from litestar.testing import TestClient
4 |
5 |
6 | def test_msgpack_app() -> None:
7 | test_data = {"a": 1, "b": "two"}
8 |
9 | with TestClient(app=app) as client:
10 | response = client.post("/", json=test_data)
11 | assert response.json() == test_data
12 |
--------------------------------------------------------------------------------
/tests/examples/test_templating/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/examples/test_templating/__init__.py
--------------------------------------------------------------------------------
/tests/unit/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/__init__.py
--------------------------------------------------------------------------------
/tests/unit/piccolo_conf.py:
--------------------------------------------------------------------------------
1 | from piccolo.conf.apps import AppRegistry
2 | from piccolo.engine import SQLiteEngine
3 |
4 | DB = SQLiteEngine(path=":memory:", check_same_thread=False)
5 |
6 | APP_REGISTRY = AppRegistry(
7 | apps=[
8 | "tests.unit.test_contrib.test_piccolo_orm.piccolo_app",
9 | ],
10 | )
11 |
--------------------------------------------------------------------------------
/tests/unit/test_asgi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_asgi/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_asgi/test_routing_trie/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_asgi/test_routing_trie/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_channels/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_channels/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_channels/util.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import asyncio
4 |
5 | from litestar.channels import Subscriber
6 |
7 |
8 | async def get_from_stream(subscriber: Subscriber, count: int) -> list[bytes]:
9 | async def getter() -> list[bytes]:
10 | items = []
11 | async for item in subscriber.iter_events():
12 | items.append(item)
13 | if len(items) == count:
14 | break
15 | return items
16 |
17 | return await asyncio.wait_for(getter(), timeout=1)
18 |
--------------------------------------------------------------------------------
/tests/unit/test_connection/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_connection/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_contrib/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_contrib/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_contrib/conftest.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import TYPE_CHECKING
4 |
5 | import pytest
6 |
7 | if TYPE_CHECKING:
8 | from typing import Callable
9 |
10 |
11 | @pytest.fixture
12 | def int_factory() -> Callable[[], int]:
13 | return lambda: 2
14 |
--------------------------------------------------------------------------------
/tests/unit/test_contrib/test_htmx/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_contrib/test_htmx/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_contrib/test_piccolo_orm/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | # this is required to ensure that piccolo discovers its conf without throwing.
4 | os.environ["PICCOLO_CONF"] = "tests.unit.piccolo_conf"
5 |
--------------------------------------------------------------------------------
/tests/unit/test_datastructures/__init_.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_datastructures/__init_.py
--------------------------------------------------------------------------------
/tests/unit/test_datastructures/test_response_header.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 | from litestar.datastructures import ResponseHeader
4 | from litestar.exceptions import ImproperlyConfiguredException
5 |
6 |
7 | def test_response_headers_validation() -> None:
8 | ResponseHeader(name="test", documentation_only=True)
9 | with pytest.raises(ImproperlyConfiguredException):
10 | ResponseHeader(name="test")
11 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from dataclasses import dataclass
4 |
5 |
6 | @dataclass
7 | class Model:
8 | a: int
9 | b: str
10 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_config.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 | from litestar.dto import DTOConfig
4 | from litestar.exceptions import ImproperlyConfiguredException
5 |
6 |
7 | def test_include_and_exclude_raises() -> None:
8 | with pytest.raises(ImproperlyConfiguredException):
9 | DTOConfig(include={"a"}, exclude={"b"})
10 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_factory/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from dataclasses import dataclass
4 |
5 |
6 | @dataclass(unsafe_hash=True)
7 | class Model:
8 | a: int
9 | b: str
10 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_factory/test_backends/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_dto/test_factory/test_backends/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_factory/test_backends/conftest.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import pytest
4 |
5 | from litestar.dto._backend import DTOBackend
6 | from litestar.dto._codegen_backend import DTOCodegenBackend
7 |
8 |
9 | @pytest.fixture()
10 | def backend_cls(use_experimental_dto_backend: bool) -> type[DTOBackend | DTOCodegenBackend]:
11 | return DTOCodegenBackend if use_experimental_dto_backend else DTOBackend
12 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_factory/test_field.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import pytest
4 |
5 | from litestar.dto.field import DTO_FIELD_META_KEY, extract_dto_field
6 | from litestar.exceptions import ImproperlyConfiguredException
7 | from litestar.typing import FieldDefinition
8 |
9 |
10 | def test_extract_dto_field_unexpected_type() -> None:
11 | with pytest.raises(ImproperlyConfiguredException):
12 | extract_dto_field(FieldDefinition.from_annotation(int), {DTO_FIELD_META_KEY: object()})
13 |
--------------------------------------------------------------------------------
/tests/unit/test_dto/test_interface.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import Any
4 | from unittest.mock import MagicMock
5 |
6 | from litestar.dto import AbstractDTO
7 | from litestar.openapi.spec.schema import Schema
8 | from litestar.typing import FieldDefinition
9 |
10 |
11 | def test_dto_interface_create_openapi_schema_default_implementation(ModelDataDTO: type[AbstractDTO]) -> None:
12 | assert (
13 | ModelDataDTO.create_openapi_schema(FieldDefinition.from_annotation(Any), MagicMock(), MagicMock()) == Schema()
14 | )
15 |
--------------------------------------------------------------------------------
/tests/unit/test_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_handlers/test_asgi_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_handlers/test_asgi_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_handlers/test_base_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_handlers/test_base_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_handlers/test_http_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_handlers/test_http_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_handlers/test_http_handlers/test_delete.py:
--------------------------------------------------------------------------------
1 | from litestar import delete
2 | from litestar.testing import create_test_client
3 |
4 |
5 | def test_handler_return_none_and_204_status_response_empty() -> None:
6 | @delete(path="/")
7 | async def route() -> None:
8 | return None
9 |
10 | with create_test_client(route_handlers=[route]) as client:
11 | response = client.delete("/")
12 | assert not response.content
13 |
--------------------------------------------------------------------------------
/tests/unit/test_handlers/test_websocket_handlers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_handlers/test_websocket_handlers/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_kwargs/__init__.py:
--------------------------------------------------------------------------------
1 | from dataclasses import dataclass
2 |
3 |
4 | @dataclass
5 | class Form:
6 | name: str
7 | age: int
8 | programmer: bool
9 | value: str
10 |
--------------------------------------------------------------------------------
/tests/unit/test_kwargs/flower.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_kwargs/flower.jpeg
--------------------------------------------------------------------------------
/tests/unit/test_logging/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_logging/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_middleware/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_middleware/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_middleware/test_session/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_middleware/test_session/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_openapi/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_openapi/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_openapi/test_constrained_fields.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_openapi/test_constrained_fields.py
--------------------------------------------------------------------------------
/tests/unit/test_openapi/test_render_plugins.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from litestar.openapi.plugins import OpenAPIRenderPlugin
4 | from litestar.testing import RequestFactory
5 |
6 |
7 | def test_render_plugin_get_openapi_json_route() -> None:
8 | request = RequestFactory().get()
9 | assert OpenAPIRenderPlugin.get_openapi_json_route(request) == "/schema/openapi.json"
10 |
--------------------------------------------------------------------------------
/tests/unit/test_openapi/test_typescript_converter/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_openapi/test_typescript_converter/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_openapi/utils.py:
--------------------------------------------------------------------------------
1 | from enum import Enum
2 |
3 | from litestar.exceptions import HTTPException
4 |
5 |
6 | class PetException(HTTPException):
7 | status_code = 406
8 |
9 |
10 | class Gender(str, Enum):
11 | MALE = "M"
12 | FEMALE = "F"
13 | OTHER = "O"
14 | ANY = "A"
15 |
16 |
17 | class LuckyNumber(int, Enum):
18 | TWO = 2
19 | SEVEN = 7
20 |
--------------------------------------------------------------------------------
/tests/unit/test_plugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_plugins/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_plugins/test_attrs/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_plugins/test_attrs/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_plugins/test_pydantic/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import TYPE_CHECKING, Literal
4 |
5 | if TYPE_CHECKING:
6 | import pydantic as pydantic_v2
7 | from pydantic import v1 as pydantic_v1
8 | from typing_extensions import TypeAlias
9 |
10 | PydanticVersion = Literal["v1", "v2"]
11 | BaseModelType: TypeAlias = "type[pydantic_v1.BaseModel| pydantic_v2.BaseModel]"
12 |
--------------------------------------------------------------------------------
/tests/unit/test_repository/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_repository/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_response/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_response/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_security/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_security/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_security/test_jwt/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_security/test_jwt/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_signature/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_signature/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_static_files/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_static_files/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_template/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_template/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_template/test_config.py:
--------------------------------------------------------------------------------
1 | from typing import TYPE_CHECKING
2 |
3 | from litestar.contrib.jinja import JinjaTemplateEngine
4 | from litestar.template.config import TemplateConfig
5 |
6 | if TYPE_CHECKING:
7 | from pathlib import Path
8 |
9 |
10 | def test_pytest_config_caches_engine_instance(tmp_path: "Path") -> None:
11 | config = TemplateConfig(
12 | directory=tmp_path,
13 | engine=JinjaTemplateEngine,
14 | )
15 | assert config.engine_instance is config.engine_instance
16 |
--------------------------------------------------------------------------------
/tests/unit/test_testing/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_testing/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_testing/test_sub_client/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_testing/test_sub_client/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_types/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_types/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tests/unit/test_utils/__init__.py
--------------------------------------------------------------------------------
/tests/unit/test_utils/test_compat.py:
--------------------------------------------------------------------------------
1 | from typing import AsyncGenerator
2 |
3 | import pytest
4 |
5 | from litestar.utils.compat import async_next
6 |
7 |
8 | async def test_async_next() -> None:
9 | async def generator() -> AsyncGenerator:
10 | yield 1
11 |
12 | gen = generator()
13 |
14 | assert await async_next(gen) == 1
15 | assert await async_next(gen, None) is None
16 | with pytest.raises(StopAsyncIteration):
17 | await async_next(gen)
18 |
--------------------------------------------------------------------------------
/tests/unit/test_utils/test_empty.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import pytest
4 |
5 | from litestar.types.empty import Empty
6 | from litestar.utils.empty import EmptyValueError, value_or_raise
7 |
8 |
9 | def test_value_or_raise_empty() -> None:
10 | with pytest.raises(EmptyValueError):
11 | value_or_raise(Empty)
12 |
13 |
14 | def test_value_or_raise_value() -> None:
15 | assert value_or_raise(1) == 1
16 |
--------------------------------------------------------------------------------
/tests/unit/test_utils/test_sequence.py:
--------------------------------------------------------------------------------
1 | from litestar.utils.sequence import find_index, unique
2 |
3 |
4 | def test_find_index() -> None:
5 | assert find_index([1, 2], lambda x: x == 2) == 1
6 | assert find_index([1, 3], lambda x: x == 2) == -1
7 |
8 |
9 | def test_unique() -> None:
10 | assert unique([1, 1, 1, 2]) == [1, 2]
11 |
12 | def x() -> None:
13 | pass
14 |
15 | def y() -> None:
16 | pass
17 |
18 | unique_functions = unique([x, x, y, y])
19 | assert unique_functions == [x, y] or [y, x]
20 | my_list: list = []
21 | assert sorted(unique([my_list, my_list, my_list])) == sorted([my_list])
22 |
--------------------------------------------------------------------------------
/tools/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/litestar-org/litestar/45ae4e87f3adc81ed57fa35b7353c5ccaa077a33/tools/__init__.py
--------------------------------------------------------------------------------
/tools/sphinx_ext/__init__.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | from typing import TYPE_CHECKING
4 |
5 | from . import changelog, missing_references, run_examples
6 |
7 | if TYPE_CHECKING:
8 | from sphinx.application import Sphinx
9 |
10 |
11 | def setup(app: Sphinx) -> dict[str, bool]:
12 | ext_config = {}
13 | ext_config.update(run_examples.setup(app))
14 | ext_config.update(missing_references.setup(app))
15 | ext_config.update(changelog.setup(app))
16 |
17 | return ext_config
18 |
--------------------------------------------------------------------------------
/typos.toml:
--------------------------------------------------------------------------------
1 | [default]
2 | extend-ignore-re = ["(?Rm)^.*(#|//)\\s*codespell:ignore\\s*$"]
3 |
4 | [default.extend-words]
5 | selectin = 'selectin'
6 | odf = 'odf'
7 | splitted = 'splitted'
8 |
9 | [files]
10 | extend-exclude = [
11 | "docs/changelog.rst",
12 | "docs/release-notes/changelog.rst",
13 | "/docs/examples/contrib/sqlalchemy/us_state_lookup.json",
14 | ]
15 |
--------------------------------------------------------------------------------