-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[django-filter] Improve constructor param types and add missing __all__ #14556
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: main
Are you sure you want to change the base?
Conversation
…asses Removed `__init__` methods from classes whose parameters are same as parent class.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Just a quick note — it’s generally a good practice to add a comment for each use of |
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.
LGTM, but one question below.
# Based on django-stubs utils/choices.pyi | ||
_Choice: TypeAlias = tuple[Any, Any] | ||
_ChoiceNamedGroup: TypeAlias = tuple[str, Iterable[_Choice]] | ||
_Choices: TypeAlias = Iterable[_Choice | _ChoiceNamedGroup] | ||
_ChoicesMapping: TypeAlias = Mapping[Any, Any] | ||
_ChoicesInput: TypeAlias = _Choices | _ChoicesMapping | type[Choices] | Callable[[], _Choices | _ChoicesMapping] |
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.
Considering that we require django-stubs, can't we just import those from there?
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.
I tried, but IIRC received a mypy error about importing non-public members. Will try again and report back.
Thanks, I'll find the time some day to fix CI errors and resolve review comments.
👍 I will convert them to |
This is all I found that could be improved in #14540. FYI @huynguyengl99
__init__
params that are inherited from parent classes. Reduced usage of loosely typed*args, **kwargs
.__init__
method type hints from classes whose parameters are same as parent class -- to avoid duplicating them.__all__
todjango_filters/rest_framework/__init__.pyi
-- the imports in this file are clearly meant as re-export, but without__all__
I believe type-checkers don't allow using them.