Skip to content

Commit

Permalink
Cleanup and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
macro1 committed Oct 13, 2014
1 parent 64c3809 commit ad5070e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
3 changes: 2 additions & 1 deletion simple_history/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _as_of_set(self, date):
queryset.order_by().values_list(pk_attr, flat=True)):
changes = queryset.filter(**{pk_attr: original_pk})
last_change = changes.latest('history_date')
if changes.filter(history_date=last_change.history_date, history_type='-').exists():
if changes.filter(history_date=last_change.history_date,
history_type='-').exists():
continue
yield last_change.instance
19 changes: 5 additions & 14 deletions simple_history/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
from django.db.models.related import RelatedObject
from django.conf import settings
from django.contrib import admin
from django.utils import importlib
from django.utils import importlib, six
try:
from django.utils.encoding import smart_text
except ImportError:
smart_text = unicode
try:
from django.utils.six import text_type
except ImportError:
text_type = unicode
from django.utils.encoding import smart_unicode as smart_text
try:
from django.utils.timezone import now
except ImportError:
Expand All @@ -28,11 +24,6 @@
from django.utils.translation import string_concat
from .manager import HistoryDescriptor

try:
basestring
except NameError:
basestring = str # Python 3 has no basestring

try:
from django.utils.encoding import python_2_unicode_compatible
except ImportError: # django 1.3 compatibility
Expand Down Expand Up @@ -62,7 +53,7 @@ def __init__(self, verbose_name=None, bases=(models.Model,),
self.user_set_verbose_name = verbose_name
self.user_related_name = user_related_name
try:
if isinstance(bases, basestring):
if isinstance(bases, six.string_types):
raise TypeError
self.bases = tuple(bases)
except TypeError:
Expand Down Expand Up @@ -254,7 +245,7 @@ def get_one_to_one_field(self, to_field, other):
# recursive
temp_field = self.__class__(to_field.rel.to._meta.object_name)
for key, val in to_field.__dict__.items():
if (isinstance(key, basestring)
if (isinstance(key, six.string_types)
and not key.startswith('_')):
setattr(temp_field, key, val)
field = self.__class__.get_field(
Expand Down Expand Up @@ -295,7 +286,7 @@ def get_field(self, other, cls):
"blank",
)
for key, val in to_field.__dict__.items():
if (isinstance(key, basestring)
if (isinstance(key, six.string_types)
and not key.startswith(excluded_prefixes)
and key not in excluded_attributes):
setattr(field, key, val)
Expand Down
2 changes: 1 addition & 1 deletion simple_history/tests/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_middleware_saves_user(self):
self.assertEqual(historical_poll.history_user, self.user,
"Middleware should make the request available to "
"retrieve history_user.")

def test_middleware_anonymous_user(self):
overridden_settings = {
'MIDDLEWARE_CLASSES':
Expand Down
4 changes: 2 additions & 2 deletions simple_history/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import unicode_literals

try:
from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
except ImportError:
from django.conf.urls.defaults import patterns, include, url
from django.conf.urls.defaults import include, url

from django.contrib import admin
from . import other_admin
Expand Down

0 comments on commit ad5070e

Please sign in to comment.