-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fixes #4506: Support Python 3 annotations on fields callables #4508
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
Changes from 4 commits
6013bcb
fe417aa
974b94d
610e8ca
14c22bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,8 @@ | |
|
|
||
| from rest_framework import ISO_8601 | ||
| from rest_framework.compat import ( | ||
| get_remote_field, unicode_repr, unicode_to_repr, value_from_object | ||
| get_remote_field, getargspec, unicode_repr, unicode_to_repr, | ||
| value_from_object | ||
| ) | ||
| from rest_framework.exceptions import ValidationError | ||
| from rest_framework.settings import api_settings | ||
|
|
@@ -59,8 +60,9 @@ def is_simple_callable(obj): | |
| if not (function or method): | ||
| return False | ||
|
|
||
| args, _, _, defaults = inspect.getargspec(obj) | ||
| len_args = len(args) if function else len(args) - 1 | ||
| parameters, defaults = getargspec(obj) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great stuff. Let's move this into a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would the work overhead to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that I don't want to bother if it's too much work.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tomchristie Yeah, moving to @xordoquy that makes more sense, yeah. I agree
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tomchristie - I don't think a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rpkilby If other parts of the application requires something more than that from |
||
| len_args = len(parameters) if function else len(parameters) - 1 | ||
| len_defaults = len(defaults) if defaults else 0 | ||
| return len_args <= len_defaults | ||
|
|
||
|
|
||
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.
An inline comment referring to which python versions each branch applies to would make sense.
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.
Also the
# type: tupleseems redundant - if we're going to describe the return type could we instead either do so more fully or not at all.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.
Return type here has been mentioned as an backward compatible for python
mypyfor python 2.I'll remove remove it now an until there's a decision made for such thing.
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.
@tomchristie I've applied the changes you've suggested.