Skip to content

Fix ASGI middleware assignment typing - #473

Closed
hansu650 wants to merge 1 commit into
pallets:mainfrom
hansu650:fix/asgi-app-middleware-typing-438
Closed

Fix ASGI middleware assignment typing#473
hansu650 wants to merge 1 commit into
pallets:mainfrom
hansu650:fix/asgi-app-middleware-typing-438

Conversation

@hansu650

Copy link
Copy Markdown

Fixes #438.

The documented app.asgi_app = middleware(app.asgi_app) pattern was treated by
type checkers as assignment to a method. This keeps the existing runtime method
unchanged while exposing an assignable ASGI application callable during static
type checking.

The existing middleware test now verifies the assignment without a type-ignore,
and the original OpenTelemetry example from the issue passes mypy.

Validation:

  • pytest: 256 passed
  • mypy on the OpenTelemetry reproduction: no issues found
  • Ruff check and format: passed
  • pre-commit: passed
  • git diff --check: passed

Full-project mypy on Windows retains one existing readline.set_completer
platform error; no new errors are introduced by this change.

@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Aug 13, 2026
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.

Installing asgi_app middleware as documented results in type errors

2 participants