Skip to content

Commit a1f5f6e

Browse files
author
Michael Barr
committed
Updated setup.py trove classifiers to include specific Python versions. Updates done for landscape.io smells: Removed django.utils.six.range import, now use hasattr(self.populate_from, '__call__') instead of django.utils.six.callable, used map() so that there was not an unused variable optgroup_value, removed kwargs from _check_choices_attribute and _check_timezone_max_length_attribute.
1 parent f422f00 commit a1f5f6e

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@
3434
'Natural Language :: English',
3535
'Operating System :: OS Independent',
3636
'Programming Language :: Python',
37+
'Programming Language :: Python :: 2',
38+
'Programming Language :: Python :: 2.5',
39+
'Programming Language :: Python :: 2.6',
3740
'Programming Language :: Python :: 2.7',
3841
'Programming Language :: Python :: 3',
42+
'Programming Language :: Python :: 3.2',
43+
'Programming Language :: Python :: 3.3',
44+
'Programming Language :: Python :: 3.4',
3945
'Topic :: Database',
4046
'Topic :: Software Development :: Libraries',
4147
],

timezone_utils/choices.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import pytz
77
import re
88

9-
# Django
10-
from django.utils.six.moves import range
11-
129
__all__ = ('get_choices', 'ALL_TIMEZONES_CHOICES', 'COMMON_TIMEZONES_CHOICES',
1310
'PRETTY_ALL_TIMEZONES_CHOICES', 'PRETTY_COMMON_TIMEZONES_CHOICES')
1411

timezone_utils/fields.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.core.exceptions import ValidationError
1515
from django.db.models import SubfieldBase
1616
from django.db.models.fields import DateTimeField, CharField
17-
from django.utils.six import callable, with_metaclass
17+
from django.utils.six import with_metaclass
1818
from django.utils.timezone import get_default_timezone
1919
from django.utils.translation import ugettext_lazy as _
2020

@@ -76,11 +76,11 @@ def formfield(self, **kwargs):
7676
# --------------------------------------------------------------------------
7777
def check(self, **kwargs): # pragma: no cover
7878
errors = super(TimeZoneField, self).check(**kwargs)
79-
errors.extend(self._check_timezone_max_length_attribute(**kwargs))
80-
errors.extend(self._check_choices_attribute(**kwargs))
79+
errors.extend(self._check_timezone_max_length_attribute())
80+
errors.extend(self._check_choices_attribute())
8181
return errors
8282

83-
def _check_timezone_max_length_attribute(self, **kwargs): # pragma: no cover
83+
def _check_timezone_max_length_attribute(self): # pragma: no cover
8484
"""Custom check() method that verifies that the `max_length` attribute
8585
covers all possible pytz timezone lengths.
8686
@@ -113,7 +113,7 @@ def _check_timezone_max_length_attribute(self, **kwargs): # pragma: no cover
113113
# When no error, return an empty list
114114
return []
115115

116-
def _check_choices_attribute(self, **kwargs): # pragma: no cover
116+
def _check_choices_attribute(self): # pragma: no cover
117117
if self.choices:
118118
warning_params = {
119119
'msg': (
@@ -129,7 +129,7 @@ def _check_choices_attribute(self, **kwargs): # pragma: no cover
129129
if isinstance(option_value, (list, tuple)):
130130
# This is an optgroup, so look inside the group for
131131
# options.
132-
for optgroup_key, optgroup_value in option_value:
132+
for optgroup_key in map(lambda x: x[0], option_value):
133133
if optgroup_key not in pytz.all_timezones:
134134
# Make sure we don't raise this error on empty
135135
# values
@@ -191,7 +191,7 @@ def pre_save(self, model_instance, add):
191191
tz = get_default_timezone()
192192

193193
if self.populate_from:
194-
if callable(self.populate_from):
194+
if hasattr(self.populate_from, '__call__'):
195195
# LinkedTZDateTimeField(
196196
# populate_from=lambda instance: instance.field.timezone
197197
# )
@@ -210,7 +210,10 @@ def pre_save(self, model_instance, add):
210210
datetime_as_timezone = value.astimezone(tz)
211211
value = tz.normalize(
212212
tz.localize(
213-
datetime.combine(date=datetime_as_timezone.date(), time=datetime_as_timezone.time())
213+
datetime.combine(
214+
date=datetime_as_timezone.date(),
215+
time=datetime_as_timezone.time()
216+
)
214217
)
215218
)
216219

0 commit comments

Comments
 (0)