Skip to content

fix(typing): allow ImmutableState instance to be passed to Litestar/AppConfig#4653

Open
osauldmy wants to merge 1 commit intolitestar-org:mainfrom
osauldmy:immutable-state-type-hint
Open

fix(typing): allow ImmutableState instance to be passed to Litestar/AppConfig#4653
osauldmy wants to merge 1 commit intolitestar-org:mainfrom
osauldmy:immutable-state-type-hint

Conversation

@osauldmy
Copy link
Copy Markdown

@osauldmy osauldmy commented Mar 29, 2026

Description

  • Hi. I wanted to use custom child of ImmutableState to be passed to Litestar instance, but mypy warned me I can't really do it, so instead of type-ignoring it, I created this PR.
  • Maybe a bit cleaner solution (but not sure if it'll need more work) is to swap inheritance, so ImmutableState inherits from State instead, but I suppose it'll still require isinstance asserts I added in tests to satisfy type-checkers.

Closes


📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4653

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.32%. Comparing base (5875eac) to head (6470192).

Files with missing lines Patch % Lines
litestar/config/app.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4653   +/-   ##
=======================================
  Coverage   67.32%   67.32%           
=======================================
  Files         292      292           
  Lines       14933    14933           
  Branches     1673     1673           
=======================================
  Hits        10054    10054           
  Misses       4743     4743           
  Partials      136      136           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant