Skip to content

fix(typing): preserve queryset type in as_manager - #421

Merged
kodiakhq[bot] merged 1 commit into
sbdchd:mainfrom
kalekseev:fix/as-manager-queryset-type-upstream
Oct 5, 2026
Merged

kodiakhq[bot] merged 1 commit into
sbdchd:mainfrom
kalekseev:fix/as-manager-queryset-type-upstream

Conversation

@kalekseev

Copy link
Copy Markdown

QuerySet.as_manager() currently loses the custom queryset type. For example, BookQuerySet.as_manager().filter().published() is rejected by type checkers even though Django returns a BookQuerySet from filter().

Return Manager[_Model, Self] so get_queryset() and queryset-returning manager methods preserve that type. The regression test also checks that model-returning methods keep their model type and the generated manager remains assignable to Manager[Book].

Validation: the full CI=1 ./s/lint pipeline passes (Ruff, mypy, Pyright, 38 tests, and ty). Also checked with ty 0.0.84 and verified the lockfile with uv lock --check --offline.

@sbdchd sbdchd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kodiakhq
kodiakhq Bot merged commit 8faad09 into sbdchd:main Oct 5, 2026
2 checks passed
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.

2 participants