Skip to content
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

Add official support for Django 2.2. #46

Merged
merged 5 commits into from
Jan 27, 2020
Merged

Conversation

joehybird
Copy link

No description provided.

@coveralls
Copy link

coveralls commented Jan 23, 2020

Coverage Status

Coverage increased (+2.0%) to 98.901% when pulling 3745f2f on joehybird:master into 65afd88 on gintas:master.

@joehybird joehybird force-pushed the master branch 3 times, most recently from 07c9314 to 81c8c54 Compare January 23, 2020 08:12
@joehybird joehybird marked this pull request as ready for review January 23, 2020 09:56
@joehybird
Copy link
Author

Why coverage from 95% (master) to 97% (this branch) is show as decreased ?

Copy link
Collaborator

@charettes charettes left a comment

Choose a reason for hiding this comment

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

Hey @joehybird!

Thank you for your patch but it seems to be doing more than simply adding support for Django 2.2.

Most of the changes you propose make sense but the fact they are all bundled together under a Add official support for Django 2.2. Improve coverage commit doesn't.

Could you break down this single commit into multiple ones that do the following:

  1. Switch TravisCI configuration to use bionic dist.
  2. Improve coverage reporting.
  3. Add support for Django 2.2.
  4. Drop support for Django 2.0 and 2.1.

tests/tests.py Outdated
@@ -35,6 +40,7 @@ def test_data_integrity(self):
# the same data, even thought it's stored differently in the DB.
self.assertEqual(value, model_test.pickle_field)
self.assertEqual(value, model_test.compressed_pickle_field)
self.assertEqual(None, model_test.nullable_pickle_field)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(None, model_test.nullable_pickle_field)
self.assertIsNone(model_test.nullable_pickle_field)

Copy link
Author

Choose a reason for hiding this comment

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

good catch :)

if django.VERSION < (2, 0):
def from_db_value(self, value, expression, connection, context):
return self.to_python(value)
else:
def from_db_value(self, value, expression, connection):
return self.to_python(value)
def from_db_value(self, value, expression, connection, context=None):
return self.to_python(value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still necessary unless you drop support for Django 1.11.

Copy link
Author

Choose a reason for hiding this comment

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

It works in all versions with full coverage, but the django 3.0 warning is back. Pretty strange because master (3.1) is ok.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@joehybird it will work but the idea is to avoid the warning on Django 3.0.

The context argument is required on Django < 2.0 and will result in a warning if present on Django < 3.1.

Please restore the previous behavior.

tox.ini Outdated
py35-{1.11,2.0,2.1,master},
py36-{1.11,2.0,2.1,master},
py37-{1.11,2.0,2.1,master}
py{27,36,37,38}-1.11,
Copy link
Collaborator

Choose a reason for hiding this comment

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

1.11 doesn't support 3.7 and 3.8, see https://djangoci.com/job/django-1.11/

tox.ini Outdated
py36-{1.11,2.0,2.1,master},
py37-{1.11,2.0,2.1,master}
py{27,36,37,38}-1.11,
py{36,37,38}-{2.0,2.1,2.2,master}
Copy link
Collaborator

Choose a reason for hiding this comment

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

2.0 and 2.1 are unsupported

2.2 supports 3.5 as well https://djangoci.com/job/django-2.2/


[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

The 2.2 LTS supports 3.5

Comment on lines +190 to +204
def test_decode_error(self):
def mock_decode_error(*args, **kwargs):
raise Exception()

model = MinimalTestingModel.objects.create(pickle_field={'foo': 'bar'})
model.save()

self.assertEqual(
{'foo': 'bar'}, MinimalTestingModel.objects.get(pk=model.pk).pickle_field
)

with patch('picklefield.fields.dbsafe_decode', mock_decode_error):
encoded_value = dbsafe_encode({'foo': 'bar'})
self.assertEqual(encoded_value, MinimalTestingModel.objects.get(pk=model.pk).pickle_field)

Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this patch have to do with Django 2.2 support?

Copy link
Author

Choose a reason for hiding this comment

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

Nothing, just coverage improvement 😄

@joehybird
Copy link
Author

Ok I will split it in different commits (should be easy... I hope so...)

Copy link
Collaborator

@charettes charettes left a comment

Choose a reason for hiding this comment

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

Thanks for the extra mile, please revert the from_db_value changes and I'll proceed with the merge.

if django.VERSION < (2, 0):
def from_db_value(self, value, expression, connection, context):
return self.to_python(value)
else:
def from_db_value(self, value, expression, connection):
return self.to_python(value)
def from_db_value(self, value, expression, connection, context=None):
return self.to_python(value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@joehybird it will work but the idea is to avoid the warning on Django 3.0.

The context argument is required on Django < 2.0 and will result in a warning if present on Django < 3.1.

Please restore the previous behavior.

@joehybird
Copy link
Author

Ok fixed :)

@charettes
Copy link
Collaborator

Awesome thanks for everything!

@charettes charettes merged commit 31a4a64 into gintas:master Jan 27, 2020
@joehybird
Copy link
Author

joehybird commented Jan 28, 2020

@charettes You can thank me with new release 🙏

@charettes
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants