-
-
Notifications
You must be signed in to change notification settings - Fork 127
Introduce flake8-pyi
in pre-commit
checks
#286
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
Conversation
rest_framework-stubs/routers.pyi
Outdated
include_root_view: bool | ||
include_format_suffixes: bool | ||
root_view_name: str | ||
default_schema_renderers = None # noqa: Y026 |
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 think None
is the default value and should be removed.
You can type this as : Any
for now.
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.
But you/I can fix these in a follow-up just as well. Up to you.
To fix the tests, you need a small change in --- a/scripts/typecheck_tests.py
+++ b/scripts/typecheck_tests.py
@@ -239,7 +239,7 @@ IGNORED_ERRORS = {
'Argument "data" to "ValidationSerializer" has incompatible type "str"',
],
"test_validation_error.py": [
- 'Argument "detail" to "ValidationError" has incompatible type "Tuple[str, str]"; expected "Union[str, List[Any], Dict[str, Any], None]"', # noqa: E501
+ 'Argument "detail" to "ValidationError" has incompatible type "Tuple[str, str]"; expected "Optional[Union[str, List[Any], Dict[str, Any]]]"', # noqa: E501
],
"test_validators.py": [
'Argument "queryset" to "BaseUniqueForValidator" has incompatible type "object";' |
Sorry, I merged another PR to master and there are merge conflicts now. I'll defer any other |
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.
Once the conflicts are solved and typecheck_tests.py
updated, I can merge this.
Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
…ypes with collections.abc Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
…oceed Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
Signed-off-by: Oleg Hoefling <[email protected]>
9998f47
to
c4b0dd3
Compare
@intgr sorry for the delay, could not finish the PR on Monday. And thank you for the hint for fixing the test error! |
Will amend the remaining issues shortly |
There seems to be a missing import:
|
Signed-off-by: Oleg Hoefling <[email protected]>
@intgr yep I didn't pay enough attention when rebasing 🤦♀️ |
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.
Thank you! Very much appreciated.
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.
Awesome.
I have made things!
This is a PR similar to typeddjango/django-stubs#1253, only for
rest_framework-stubs
.All statements that are unclear on how to proceed are marked with
# noqa:
in the code, with the exception ofcompat.pyi
, which has additional rules turned off insetup.cfg
.There are some low-hanging fruits to fix, e.g.
djangorestframework-stubs/rest_framework-stubs/fields.pyi
Line 350 in 89f8925
should obviously be
or
djangorestframework-stubs/rest_framework-stubs/routers.pyi
Line 60 in 89f8925
which could be set to
default_schema_renderers: None
, or removed altogether.