Skip to content

Commit

Permalink
Cleanup of flake8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Mar 17, 2015
1 parent c8fcfcf commit 1afca6e
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 98 deletions.
3 changes: 1 addition & 2 deletions django_hstore/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
warnings.warn("""\n
DJANGO_HSTORE_GLOBAL_REGISTER setting is deprecated since django-hstore 1.2.5 and will be removed in 1.3.0.
Use DJANGO_HSTORE_ADAPTER_REGISTRATION by setting it either to 'global' or 'connection'.
""",
DeprecationWarning)
""", DeprecationWarning)


class ConnectionCreateHandler(object):
Expand Down
2 changes: 1 addition & 1 deletion django_hstore/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UnicodeMixin(object):
Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3.
"""
if sys.version_info[0] >= 3: # Python 3
if sys.version_info[0] >= 3: # Python 3
def __str__(self):
return self.__unicode__()
else: # Python 2
Expand Down
2 changes: 1 addition & 1 deletion django_hstore/descriptors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from .dict import *
from .dict import HStoreDict, HStoreReferenceDict


__all__ = [
Expand Down
3 changes: 1 addition & 2 deletions django_hstore/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class HStoreDict(UnicodeMixin, dict):
"""
A dictionary subclass which implements hstore support.
"""

schema_mode = False # python2.6 compatibility

def __init__(self, value=None, field=None, instance=None, schema_mode=False, **kwargs):
Expand Down Expand Up @@ -84,7 +83,7 @@ def get(self, *args):
key = args[0]
try:
return self.__getitem__(key)
except KeyError as e:
except KeyError:
if len(args) > 1:
return args[1] # return default value
else:
Expand Down
11 changes: 6 additions & 5 deletions django_hstore/fields.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import unicode_literals, absolute_import

from django.db import models, connection
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ImproperlyConfigured
from django import get_version

from .descriptors import *
from .dict import *
from .virtual import *
from .descriptors import HStoreDescriptor, HStoreReferenceDescriptor
from .dict import HStoreDict, HStoreReferenceDict
from .virtual import create_hstore_virtual_field
from . import forms, utils


Expand Down Expand Up @@ -70,7 +70,8 @@ def south_field_triple(self):


if get_version() >= '1.7':
from .lookups import *
from .lookups import (HStoreGreaterThan, HStoreGreaterThanOrEqual, HStoreLessThan,
HStoreLessThanOrEqual, HStoreContains, HStoreIContains, HStoreIsNull)

HStoreField.register_lookup(HStoreGreaterThan)
HStoreField.register_lookup(HStoreGreaterThanOrEqual)
Expand Down
9 changes: 4 additions & 5 deletions django_hstore/hstore.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from django_hstore.fields import DictionaryField, ReferencesField
from django_hstore.managers import HStoreManager
from django_hstore.fields import DictionaryField, ReferencesField # noqa
from django_hstore.managers import HStoreManager # noqa


try:
from django_hstore.managers import HStoreGeoManager
from django_hstore.managers import HStoreGeoManager # noqa
except:
# django.contrib.gis is not configured properly
pass

import django
if django.get_version() < '1.7':
from . import apps

from . import apps # noqa
7 changes: 2 additions & 5 deletions django_hstore/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import django
from django.db import models
from django.core.exceptions import ValidationError

from .fields import DictionaryField
from .fields import DictionaryField # noqa


if django.get_version() < '1.7':
from . import apps
from . import apps # noqa
4 changes: 2 additions & 2 deletions django_hstore/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def deconstruct(self, *args, **kwargs):
specific for django 1.7 and greater (migration framework)
"""
name, path, args, kwargs = super(VirtualField, self).deconstruct(*args, **kwargs)
return (name, path, args, { 'default': kwargs.get('default')})
return (name, path, args, {'default': kwargs.get('default')})

# support DateTimeField
if BaseField == models.DateTimeField and (kwargs.get('null') or kwargs.get('blank')):
Expand All @@ -106,7 +106,7 @@ def value_to_string(self, obj):
val = self._get_val_from_obj(obj)
try:
return '' if val is None else val.isoformat()
except AttributeError as e:
except AttributeError:
return val
VirtualField.value_to_string = value_to_string

Expand Down
3 changes: 2 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# -*- coding: utf-8 -*-


import os, sys
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
sys.path.insert(0, "tests")

Expand Down
6 changes: 3 additions & 3 deletions tests/django_hstore_tests/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin
from django import get_version
from .models import *
from .models import * # noqa


class DataBagAdmin(admin.ModelAdmin):
Expand All @@ -18,7 +18,7 @@ class DefaultsModelAdmin(admin.ModelAdmin):

class RefsBagAdmin(admin.ModelAdmin):
pass


admin.site.register(DataBag, DataBagAdmin)
admin.site.register(DefaultsModel, DefaultsModelAdmin)
Expand All @@ -28,5 +28,5 @@ class RefsBagAdmin(admin.ModelAdmin):
if get_version()[0:3] >= '1.6':
class SchemaDataBagAdmin(admin.ModelAdmin):
list_display = ['name']

admin.site.register(SchemaDataBag, SchemaDataBagAdmin)
6 changes: 4 additions & 2 deletions tests/django_hstore_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NullableDataBag(HStoreModel):
name = models.CharField(max_length=32)
data = hstore.DictionaryField(null=True)


class RefsBag(HStoreModel):
name = models.CharField(max_length=32)
refs = hstore.ReferencesField()
Expand All @@ -65,7 +66,7 @@ class BadDefaultsModel(models.Model):

class DefaultsInline(models.Model):
parent = models.ForeignKey(DefaultsModel)
d = hstore.DictionaryField(default={ 'default': 'yes' })
d = hstore.DictionaryField(default={'default': 'yes'})


class NumberedDataBag(HStoreModel):
Expand All @@ -79,7 +80,7 @@ class UniqueTogetherDataBag(HStoreModel):
data = hstore.DictionaryField()

class Meta:
unique_together = ("name", "data")
unique_together = ('name', 'data')

if get_version()[0:3] >= '1.6':
class SchemaDataBag(HStoreModel):
Expand Down Expand Up @@ -198,6 +199,7 @@ class SchemaDataBag(HStoreModel):
# if geodjango is in use define Location model, which contains GIS data
if GEODJANGO:
from django.contrib.gis.db import models as geo_models

class Location(geo_models.Model):
name = geo_models.CharField(max_length=32)
data = hstore.DictionaryField()
Expand Down
Loading

0 comments on commit 1afca6e

Please sign in to comment.