-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix 1.10 deprecation warnings #4488
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
|
Thanks, looks good. To be reviewed. |
tests/conftest.py
Outdated
| PASSWORD_HASHERS=( | ||
| 'django.contrib.auth.hashers.MD5PasswordHasher', | ||
| ), | ||
| **{ |
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.
- Why the odd syntax choice here?
- Is it intentional that this block has moved?
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.
- Only way I could think to handle
MIDDLEWAREvsMIDDLEWARE_CLASSES. Is there a better way of doing this? - I could have kept it in the same location, but it would have seemed weird to have a kwarg expansion in the middle of the argument assignments.
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 understand that
MIDDLEWAREis the new setting name, andMIDDLEWARE_CLASSESis deprecated, but is it possible to have both of them in the settings without causing issues? That would avoid the need for doing the keyword argument unpacking. - I'm pretty sure keyword unpacking is only allowed at the end of the argument list, so that would explain the need to have it at the end.
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.
is it possible to have both of them in the settings without causing issues?
Yep - that worked.
lovelydinosaur
left a comment
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.
Great work. Only thing I can see that needs discussion is the slight oddity of the syntax and moving of MIDDLEWARE_CLASSES setting.
rest_framework/serializers.py
Outdated
|
|
||
| def update(self, instance, validated_data): | ||
| raise_errors_on_nested_writes('update', self, validated_data) | ||
| info = model_meta.get_field_info(instance) |
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'm still hesitant about the extra call to get_field_info here. How performance intensive is it to redo all of the field introspection?
|
btw - there are two remaining deprecation warnings regarding the use of
Not sure how to fix these, and tbh I'm not too worried about it as it's internal to the test suite. |
tests/test_atomic_requests.py
Outdated
| connection.features.uses_savepoints, | ||
| "'atomic' requires transactions and savepoints." | ||
| ) | ||
| @override_settings(ROOT_URLCONF='tests.test_atomic_requests') |
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.
btw, this test did not fail despite the urls property having been fully deprecated in 1.10
Description
Fixes a number of deprecation warnings generated by DRF. The to-many fix is the only one that really concerns me, as it makes a call to
model_meta.get_field_info. Not sure if there's a better way to pass that information to thecreate/updatemethods.There isn't really an easy way to test this without manually running the tests with the
-Werrorflag. That said, django-guardian also generates a number of warnings too. Just to test it out, you can install my fork, which has the fixes applied.