Skip to content

Commit

Permalink
Merge pull request #50 from carltongibson/patch-1
Browse files Browse the repository at this point in the history
Updated DEFAULT_PROTOCOL to 3.
  • Loading branch information
charettes committed Jun 5, 2020
2 parents 44dfeb9 + 5bc1900 commit c615d9d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: false
language: python
cache: pip
python:
- 2.7
- 3.5
- 3.6
- 3.7
Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ since it is never a good idea to have a PickledObjectField be user editable.
Changes
-------

UNRELEASED
==========

* Dropped support for Python 2.
* Updated default pickle protocol to version 3.
* Added testing against Django 3.0.
* Dropped support for Django 1.11.

Changes in version 2.1.0
========================

Expand Down
2 changes: 1 addition & 1 deletion picklefield/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import unicode_literals

DEFAULT_PROTOCOL = 2
DEFAULT_PROTOCOL = 3
12 changes: 6 additions & 6 deletions picklefield/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PickledObject(str):
"""


class _ObjectWrapper(object):
class _ObjectWrapper:
"""
A class used to wrap object that have properties that may clash with the
ORM internals.
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self, *args, **kwargs):
self.protocol = kwargs.pop('protocol', DEFAULT_PROTOCOL)
self.copy = kwargs.pop('copy', True)
kwargs.setdefault('editable', False)
super(PickledObjectField, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def get_default(self):
"""
Expand All @@ -114,7 +114,7 @@ def get_default(self):
return self.default()
return self.default
# If the field doesn't have a default, then we punt to models.Field.
return super(PickledObjectField, self).get_default()
return super().get_default()

def _check_default(self):
if self.has_default() and isinstance(self.default, (list, dict, set)):
Expand All @@ -139,7 +139,7 @@ def _check_default(self):
return []

def check(self, **kwargs):
errors = super(PickledObjectField, self).check(**kwargs)
errors = super().check(**kwargs)
errors.extend(self._check_default())
return errors

Expand Down Expand Up @@ -167,7 +167,7 @@ def to_python(self, value):
return value

def pre_save(self, model_instance, add):
value = super(PickledObjectField, self).pre_save(model_instance, add)
value = super().pre_save(model_instance, add)
return wrap_conflictual_object(value)

if DJANGO_VERSION < (2, 0):
Expand Down Expand Up @@ -211,4 +211,4 @@ def get_lookup(self, lookup_name):
"""
if lookup_name not in ['exact', 'in', 'isnull']:
raise TypeError('Lookup type %s is not supported.' % lookup_name)
return super(PickledObjectField, self).get_lookup(lookup_name)
return super().get_lookup(lookup_name)
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ combine_as_imports=true
include_trailing_comma=true
multi_line_output=5
not_skip=__init__.py

[wheel]
universal = 1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand All @@ -39,6 +38,7 @@
],
keywords=['django pickle model field'],
packages=find_packages(exclude=['tests', 'tests.*']),
python_requires='>=3',
install_requires=['Django>=1.11'],
extras_require={
'tests': ['tox'],
Expand Down
17 changes: 5 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ args_are_paths = false
envlist =
flake8,
isort,
py27-1.11,
py35-{1.11,2.2},
py36-{1.11,2.2,3.0,master},
py37-{1.11,2.2,3.0,master},
py35-2.2,
py36-{2.2,3.0,master},
py37-{2.2,3.0,master},
py38-{2.2,3.0,master},

[tox:travis]
2.7 = py27
3.5 = py35
3.6 = py36
3.7 = py37
3.8 = py38

[testenv]
basepython =
py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
Expand All @@ -29,23 +26,19 @@ commands =
{envpython} -R -Wonce {envbindir}/coverage run --branch -m django test -v2 --settings=tests.settings {posargs}
coverage report -m
deps =
py27: mock
coverage
1.11: Django>=1.11,<2.0
2.0: Django>=2.0,<2.1
2.1: Django>=2.1,<2.2
2.2: Django>=2.2,<3.0
3.0: Django>=3.0,<3.1
master: https://github.com/django/django/archive/master.tar.gz

[testenv:flake8]
usedevelop = false
basepython = python2.7
basepython = python3.6
commands = flake8
deps = flake8

[testenv:isort]
usedevelop = false
basepython = python2.7
basepython = python3.6
commands = isort --recursive --check-only --diff picklefield tests
deps = isort==4.2.5

0 comments on commit c615d9d

Please sign in to comment.