Auto-activate for advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy — use sqlspec.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for litestar_autowire, AutowirePlugin, AutowireConfig, domain_packages, AutowireIntegration, AutowireLoader, or clear_autowire_cache. Not for manual Router composition — use explicit routes.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
litestar-autowire 0.2.0 discovers Litestar controllers and event listeners
from domain packages. It can also load optional integration modules without
turning application setup into a central list of every domain component.
Use Autowire when the project already groups features into stable Python
packages. Keep manual Router and plugin composition when the app is small,
route registration is intentionally explicit, or packages do not follow a
consistent convention.
domain_packages.litestar_autowire.integrations (DishkaIntegration(), QueuesIntegration()).clear_autowire_cache() when tests create, replace, or remove modules.pip install litestar-autowire==0.2.0
Install only the integrations already used by the project:
pip install "litestar-autowire[dishka]==0.2.0"
pip install "litestar-autowire[queues]==0.2.0"
my_app/
└── domains/
├── accounts/
│ ├── controllers.py
│ ├── events.py
│ └── jobs.py
└── billing/
└── routes.py
Regular packages and PEP 420 namespace packages are supported. Autowire checks the configured root and each direct child package. Read Discovery before changing module conventions or debugging a missing component.
from litestar import Litestar
from litestar_autowire import AutowireConfig, AutowirePlugin
autowire = AutowirePlugin(
AutowireConfig(domain_packages=["my_app.domains"]),
)
app = Litestar(plugins=[autowire])
The default component modules are:
| Component | Module names | Enabled |
|---|---|---|
| Controllers | controllers, routes, controller, route | Yes |
| Event listeners | events, listeners | Yes |
| Litestar Queues tasks | jobs | Only with integrations=["queues"] |
AutowireConfig fields (all constructor arguments are keyword-only):
| Field | Default | Contract |
|---|---|---|
domain_packages | () | str | Iterable[str] normalized to tuple[str, ...] |
integrations | () | Built-in names ("dishka", "queues") or AutowireIntegration objects |
discover_controllers | True | Register discovered Controller subclasses |
discover_listeners | True | Register discovered EventListener instances |
controller_modules | ("controllers", "routes", "controller", "route") | str | Iterable[str] normalized to tuple[str, ...] |
listener_modules | ("events", "listeners") | str | Iterable[str] normalized to tuple[str, ...] |
task_modules | ("jobs",) | str | Iterable[str] normalized to tuple[str, ...] |
router_class | None | Optional router wrapper (litestar.Router or compatible type) |
before_request | None | Optional hook attached to the wrapper router |
after_response | None | Optional hook attached to the wrapper router |
force_reload_tasks | False | Passed to litestar_queues.discover_tasks(force_reload=...) |
log_discovered | True | Defer discovery summary logs to the Litestar startup hook |
Use config.integration_enabled(name) to check whether an integration with name is configured.
Customize module names without changing the domain layout:
config = AutowireConfig(
domain_packages=["my_app.domains"],
controller_modules=["http"],
listener_modules=["subscribers"],
discover_listeners=False,
)
By default, discovered controller classes are appended directly to
AppConfig.route_handlers. Set router_class=Router when the project needs a
wrapper for router-level before_request or after_response hooks:
from litestar import Router
from litestar_autowire import AutowireConfig
config = AutowireConfig(
domain_packages=["my_app.domains"],
router_class=Router,
before_request=set_request_context,
after_response=record_response,
)
The wrapper is constructed with path="/", the discovered controller classes,
and the configured hooks. Use integrations=["dishka"] instead when the
project already uses Dishka and needs DishkaRouter. See
Integrations.
AutowirePlugin(AutowireConfig(...)) in the app plugin list.Controller subclasses and EventListener objects.AutowirePlugin, AutowireConfig, AutowireContext,
AutowireIntegration, AutowireLoader, DishkaIntegration,
QueuesIntegration, clear_autowire_cache, discover_controllers,
discover_feature_packages, discover_listeners, discover_queue_tasks,
find_controllers_in_module, and find_listeners_in_module. There is no
AutowireRegistry, DomainMetadata, DiscoveredCLI, DiscoveredController,
DiscoveredJob, DiscoveredProvider, DiscoveredSchema, DiscoveredSignal,
LitestarQueuesIntegration, or SAQIntegration (use AutowireLoader for
SAQ or custom module registries).queues integration
must be selected and its optional dependency installed.router_class and expect Dishka to replace it.
DishkaIntegration preserves an already selected router class.FromDishka[...] types under if TYPE_CHECKING: when
from __future__ import annotations is enabled in controller modules.
DishkaRouter.register calls typing.get_type_hints() on each controller
handler at registration time, which raises NameError if injected types are
absent from runtime module globals or defined only in a function scope.Controller class across unit tests after DishkaRouter
registration without restoring get_route_handlers. DishkaRouter.register
monkey-patches ControllerSubclass.get_route_handlers in-place on the class.dishka or queues. Built-in
name collisions fail during configuration.domain_packages contains importable dotted package roots.FromDishka[...] dependency
types importable at runtime rather than inside if TYPE_CHECKING: under
from __future__ import annotations.AutowireIntegration and use unique names.router_class.clear_autowire_cache() around dynamic module changes and
restore Controller.get_route_handlers when reusing controllers with Dishka.from litestar import Controller, get
class AccountController(Controller):
path = "/accounts"
@get()
async def list_accounts(self) -> list[dict[str, str]]:
return [{"name": "primary"}]
from litestar import Litestar
from litestar_autowire import AutowireConfig, AutowirePlugin
app = Litestar(
plugins=[
AutowirePlugin(
AutowireConfig(
domain_packages=["my_app.domains"],
discover_controllers=True,
discover_listeners=True,
)
)
],
)
Autowire imports my_app.domains.accounts.controllers, registers
AccountController, and checks the configured listener module names. It does
not load jobs.py until the queues integration is selected.
AutowireLoader, router selection, Dishka, and Litestar Queuesまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Auto-activate for advanced_alchemy, alembic/, SQLAlchemyAsyncRepositoryService, SQLAlchemyAsyncConfig, repository_type, service_class, filters, or storage. Not for raw SQLAlchemy — use sqlspec.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Litestar, Controller, Router, @get/@post, FromPath, MsgspecDTO, OpenAPIConfig, Provide, FromDishka, Guard, ASGIMiddleware, HTTPException, ChannelsPlugin, or WebSocket. Not for standalone libs.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Google ADK, LlmAgent, Runner, SQLSpecSessionService, google-genai, AgentRuntime, SpecTree, DynamicWorkflow, FunctionTool, or SSE agent chats. Not for offline ML training.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for uv build, hatch build, PyApp, PYAPP_*, wheel assets, GitHub release matrices, cargo-zigbuild, or python-build-standalone. Not for runtime deployment.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for Dockerfile, compose, Railway, Cloud Run, GKE, systemd, Kubernetes, Terraform, deploy scripts, or granian/litestar run at runtime. Not for packaging artifacts.
日本語の概要は準備中です。原文の説明を表示しています。
Auto-activate for litestar_email, EmailPlugin, EmailConfig, EmailService, EmailMessage, SMTPConfig, ResendConfig, SendGridConfig, MailgunConfig, SESConfig. Not for marketing APIs — use vendor SDKs.
日本語の概要は準備中です。原文の説明を表示しています。