-
-
Notifications
You must be signed in to change notification settings - Fork 521
make code in contrib/admin/filters.pyi properly use generics #2908
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
base: master
Are you sure you want to change the base?
make code in contrib/admin/filters.pyi properly use generics #2908
Conversation
UnknownPlatypus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few open questions
| _ModelT = TypeVar("_ModelT", bound=Model) | ||
| _ST = TypeVar("_ST", contravariant=True) | ||
| _GT = TypeVar("_GT", covariant=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we / should we share these typevar definition with the other places with matching ones ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No preference, I have not seen anyone doing it tho
| used_parameters: dict[str, bool | datetime | str] | ||
| def __init__( | ||
| self, request: HttpRequest, params: dict[str, str], model: type[Model], model_admin: ModelAdmin | ||
| self, request: HttpRequest, params: dict[str, str], model: type[Model], model_admin: ModelAdmin[_ModelT] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should model also be modelT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, will fix
I have made things!
I improved usage of generics in
contrib/admin/filters.pyiRelated issues
I haven't been able to find any.