Skip to content

Conversation

@rpkilby
Copy link
Contributor

@rpkilby rpkilby commented Sep 15, 2016

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 the create/update methods.

There isn't really an easy way to test this without manually running the tests with the -Werror flag. 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.

@lovelydinosaur
Copy link
Contributor

Thanks, looks good. To be reviewed.

@lovelydinosaur lovelydinosaur added this to the 3.4.7 Release milestone Sep 15, 2016
PASSWORD_HASHERS=(
'django.contrib.auth.hashers.MD5PasswordHasher',
),
**{
Copy link
Contributor

@lovelydinosaur lovelydinosaur Sep 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why the odd syntax choice here?
  2. Is it intentional that this block has moved?

Copy link
Contributor Author

@rpkilby rpkilby Sep 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Only way I could think to handle MIDDLEWARE vs MIDDLEWARE_CLASSES. Is there a better way of doing this?
  2. 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I understand that MIDDLEWARE is the new setting name, and MIDDLEWARE_CLASSES is 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.
  2. 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.

Copy link
Contributor Author

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.

Copy link
Contributor

@lovelydinosaur lovelydinosaur left a 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.


def update(self, instance, validated_data):
raise_errors_on_nested_writes('update', self, validated_data)
info = model_meta.get_field_info(instance)
Copy link
Contributor Author

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?

@rpkilby
Copy link
Contributor Author

rpkilby commented Sep 15, 2016

btw - there are two remaining deprecation warnings regarding the use of include:

  • tests/test_routers.py:61
  • tests/test_versioning.py:166
RemovedInDjango20Warning: Specifying a namespace in django.conf.urls.include() without providing an app_name is deprecated. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

Not sure how to fix these, and tbh I'm not too worried about it as it's internal to the test suite.

connection.features.uses_savepoints,
"'atomic' requires transactions and savepoints."
)
@override_settings(ROOT_URLCONF='tests.test_atomic_requests')
Copy link
Contributor Author

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

@lovelydinosaur lovelydinosaur modified the milestones: 3.4.7 Release, 3.4.8 Release Sep 21, 2016
@rpkilby rpkilby closed this Sep 21, 2016
@lovelydinosaur lovelydinosaur modified the milestones: 3.4.8 Release, 3.5.0 Release Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants