-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
Upgrade to Mypy 1.0 #339
Upgrade to Mypy 1.0 #339
Conversation
Approved CI run. |
Some if not all of the typecheck errors are due to upstream changes in DRF test suite, not from upgrading mypy. |
Do we just add them as excluded errors in |
I've looked at each error, and checked if it's something we're missing in stubs or a false positive. Usually it's a false positive, or some new feature that has been merged in DRF but will be in the next version (e.g. #338). But it's annoying and confusing, especially for new contributors, when CI checks start to fail due to unrelated changes. So I've been thinking that we may want to freeze the git commit hash that we check (like is already done in django-stubs). But the downside is that then we would have to periodically update this hash, something that's been a bit neglected in django-stubs. |
13ba668
to
36c5e8a
Compare
I rebased your branch. The remaining CI errors are from mypy 1.0 update. |
Thanks! For convenience, here are the relevant files:
Problem 1
These seem to be exclusively complaining about this pattern: composed_perm = permissions.IsAuthenticated | permissions.AllowAny
assert composed_perm().has_permission(request, None) is True This only happens when you I don't really understand why this would happen, since the stub definition seems to treat Problem 2
These are all coming from: self.versioning_class() Where The stub defines this as nullable, and DRF source seems to agree that this is possible, so I can add an ignore for this one. |
Yes indeed, mypy thinks I always hated how DRF requires permissions checks to be classes, not instances. This can cause problems in actual user code. Maybe report a mypy bug? Mypy could look at whether a class overrides the |
…tubs into christian/mypy-1.0
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.
There are still some test failures. Sorry, I could have approved the CI run earlier.
Done! And I ran |
I've approved the CI run. You shouldn't need approvals once you've become a contributor. |
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.
Thanks!
I have made things!
Upgrade to Mypy 1.0
Related issues
Refs python/mypy#13685
Closes #340