Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hint improvements for string promises, manager, query set #1272

Merged
merged 4 commits into from Nov 26, 2022

Conversation

benspaulding
Copy link
Contributor

I originally dove in to address issues where type hints only accepted str but should accept _StrOrPromise | None, so there are two commits about that.

One commit changes the hints in the signatures of django.db.models.query._QuerySet.as_manager() and django.db.models.manager.BaseManager.from_queryset() to use generics/typevars instead of Any.

Finally, I found two places with what I think are unnecessary # type: ignore comments.

  • If you want each of those in a different PR, please let me know!
  • If you only want some of the commits feel free to cherry-pick them yourself, if that is easier.

Let me know if you have any feedback or questions. Thanks!

@sobolevn
Copy link
Member

One commit changes the hints in the signatures of django.db.models.query._QuerySet.as_manager() and django.db.models.manager.BaseManager.from_queryset() to use generics/typevars instead of Any.

This is handled by our plugin, but in case it will help users without the plugin to have better types (and won't break anything): I am ok with it.

@benspaulding
Copy link
Contributor Author

@sobolevn wrote:

This is handled by our plugin, but in case it will help users without the plugin to have better types (and won't break anything): I am ok with it.

Ah, good to know! I didn’t realize it handled that. I was looking through the stubs to see why I wasn’t getting what I expected, but that was in my editor, not with mypy directly. So if it works for y’all it would be handy to see this accepted.

Thanks!

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thank you!

@sobolevn sobolevn merged commit 9a34eae into typeddjango:master Nov 26, 2022
@benspaulding benspaulding deleted the type-hint-improvements branch November 29, 2022 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants