Skip to content

fix: mark repository handler parameters with NamedDependency - #48

Merged
lesnik512 merged 3 commits into
mainfrom
fix/named-dependency-markers
Sep 27, 2026
Merged

lesnik512 merged 3 commits into
mainfrom
fix/named-dependency-markers

Conversation

@lesnik512

@lesnik512 lesnik512 commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Litestar 2.23+ emits a LitestarDeprecationWarning for every dependency parameter that is resolved by name without an explicit marker ("Inferred dependencies will stop working in Litestar 3.0"). The test suite printed 216 of these: 8 handlers times 27 app builds.

  • Annotate the decks_repository / cards_repository handler parameters in app/api/decks.py and app/api/cards.py with litestar.di.NamedDependency[...] (Litestar 2.24.0, as pinned in uv.lock). The dependency registration in app/application.py via modern_di_litestar.FromDI is unchanged; NamedDependency only marks the parameter as injected by name.
  • Ignore ruff's TC rules globally instead of per-file / inline noqa: TC00x. Litestar resolves handler annotations at runtime and modern-di reads creator annotations, so moving those imports into TYPE_CHECKING blocks (which ruff --fix with unsafe fixes would do) breaks app startup. This replaces the app/resources/*.py per-file ignore and the six inline noqa comments in app/api/.

Test plan

  • just test: 31 passed, 0 warnings (was 31 passed, 216 warnings)
  • just lint: ruff and ty clean

@lesnik512
lesnik512 merged commit 365a4b4 into main Sep 27, 2026
2 checks passed
@lesnik512
lesnik512 deleted the fix/named-dependency-markers branch September 27, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant