Skip to content

make code in contrib/admin/filters.pyi properly use generics#2908

Open
Vulwsztyn wants to merge 3 commits intotypeddjango:masterfrom
Vulwsztyn:contrib_admin_filters_generics
Open

make code in contrib/admin/filters.pyi properly use generics#2908
Vulwsztyn wants to merge 3 commits intotypeddjango:masterfrom
Vulwsztyn:contrib_admin_filters_generics

Conversation

@Vulwsztyn
Copy link
Copy Markdown

I have made things!

I improved usage of generics in contrib/admin/filters.pyi

Related issues

I haven't been able to find any.

Copy link
Copy Markdown
Contributor

@UnknownPlatypus UnknownPlatypus left a 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

Comment on lines +24 to +26
_ModelT = TypeVar("_ModelT", bound=Model)
_ST = TypeVar("_ST", contravariant=True)
_GT = TypeVar("_GT", covariant=True)
Copy link
Copy Markdown
Contributor

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 ?

Copy link
Copy Markdown
Author

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]
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yeah, will fix

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.

2 participants