Fixed flake8 warnings on Python 3.
This commit is contained in:
parent
ccfb5c7408
commit
47fcbe506c
|
@ -245,7 +245,7 @@ WHEN (new.%(col_name)s IS NULL)
|
||||||
# http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
|
# http://cx-oracle.sourceforge.net/html/cursor.html#Cursor.statement
|
||||||
# The DB API definition does not define this attribute.
|
# The DB API definition does not define this attribute.
|
||||||
statement = cursor.statement
|
statement = cursor.statement
|
||||||
if statement and six.PY2 and not isinstance(statement, unicode):
|
if statement and six.PY2 and not isinstance(statement, unicode): # NOQA: unicode undefined on PY3
|
||||||
statement = statement.decode('utf-8')
|
statement = statement.decode('utf-8')
|
||||||
# Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's
|
# Unlike Psycopg's `query` and MySQLdb`'s `_last_executed`, CxOracle's
|
||||||
# `statement` doesn't contain the query parameters. refs #20010.
|
# `statement` doesn't contain the query parameters. refs #20010.
|
||||||
|
|
|
@ -17,7 +17,7 @@ DEFAULT_DB_ALIAS = 'default'
|
||||||
DJANGO_VERSION_PICKLE_KEY = '_django_version'
|
DJANGO_VERSION_PICKLE_KEY = '_django_version'
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception if six.PY3 else StandardError):
|
class Error(Exception if six.PY3 else StandardError): # NOQA: StandardError undefined on PY3
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ class LazyObject(object):
|
||||||
__bool__ = new_method_proxy(bool)
|
__bool__ = new_method_proxy(bool)
|
||||||
else:
|
else:
|
||||||
__str__ = new_method_proxy(str)
|
__str__ = new_method_proxy(str)
|
||||||
__unicode__ = new_method_proxy(unicode)
|
__unicode__ = new_method_proxy(unicode) # NOQA: unicode undefined on PY3
|
||||||
__nonzero__ = new_method_proxy(bool)
|
__nonzero__ = new_method_proxy(bool)
|
||||||
|
|
||||||
# Introspection support
|
# Introspection support
|
||||||
|
|
|
@ -380,7 +380,7 @@ def html_safe(klass):
|
||||||
)
|
)
|
||||||
klass_unicode = klass.__unicode__
|
klass_unicode = klass.__unicode__
|
||||||
klass.__unicode__ = lambda self: mark_safe(klass_unicode(self))
|
klass.__unicode__ = lambda self: mark_safe(klass_unicode(self))
|
||||||
klass.__html__ = lambda self: unicode(self)
|
klass.__html__ = lambda self: unicode(self) # NOQA: unicode undefined on PY3
|
||||||
else:
|
else:
|
||||||
if '__str__' not in klass.__dict__:
|
if '__str__' not in klass.__dict__:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
|
@ -208,7 +208,10 @@ class TranslationTests(SimpleTestCase):
|
||||||
result = ungettext_lazy('%(name)s has %(num)d good result', '%(name)s has %(num)d good results', 4)
|
result = ungettext_lazy('%(name)s has %(num)d good result', '%(name)s has %(num)d good results', 4)
|
||||||
self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results")
|
self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results")
|
||||||
# Now with a long
|
# Now with a long
|
||||||
result = ungettext_lazy('%(name)s has %(num)d good result', '%(name)s has %(num)d good results', long(4))
|
result = ungettext_lazy(
|
||||||
|
'%(name)s has %(num)d good result', '%(name)s has %(num)d good results',
|
||||||
|
long(4) # NOQA: long undefined on PY3
|
||||||
|
)
|
||||||
self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results")
|
self.assertEqual(result % {'name': 'Joe', 'num': 4}, "Joe has 4 good results")
|
||||||
|
|
||||||
@override_settings(LOCALE_PATHS=extended_locale_paths)
|
@override_settings(LOCALE_PATHS=extended_locale_paths)
|
||||||
|
@ -470,7 +473,7 @@ class FormattingTests(SimpleTestCase):
|
||||||
self.d = datetime.date(2009, 12, 31)
|
self.d = datetime.date(2009, 12, 31)
|
||||||
self.dt = datetime.datetime(2009, 12, 31, 20, 50)
|
self.dt = datetime.datetime(2009, 12, 31, 20, 50)
|
||||||
self.t = datetime.time(10, 15, 48)
|
self.t = datetime.time(10, 15, 48)
|
||||||
self.l = 10000 if PY3 else long(10000)
|
self.l = 10000 if PY3 else long(10000) # NOQA: long undefined on PY3
|
||||||
self.ctxt = Context({
|
self.ctxt = Context({
|
||||||
'n': self.n,
|
'n': self.n,
|
||||||
't': self.t,
|
't': self.t,
|
||||||
|
|
|
@ -797,10 +797,11 @@ class PromiseTest(test.SimpleTestCase):
|
||||||
|
|
||||||
@unittest.skipIf(six.PY3, "Python 3 has no `long` type.")
|
@unittest.skipIf(six.PY3, "Python 3 has no `long` type.")
|
||||||
def test_BigIntegerField(self):
|
def test_BigIntegerField(self):
|
||||||
lazy_func = lazy(lambda: long(9999999999999999999), long)
|
# NOQA: long undefined on PY3
|
||||||
|
lazy_func = lazy(lambda: long(9999999999999999999), long) # NOQA
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
BigIntegerField().get_prep_value(lazy_func()),
|
BigIntegerField().get_prep_value(lazy_func()),
|
||||||
long)
|
long) # NOQA
|
||||||
|
|
||||||
def test_BinaryField(self):
|
def test_BinaryField(self):
|
||||||
lazy_func = lazy(lambda: b'', bytes)
|
lazy_func = lazy(lambda: b'', bytes)
|
||||||
|
|
|
@ -2245,17 +2245,18 @@ class QuerySetSupportsPythonIdioms(TestCase):
|
||||||
|
|
||||||
@unittest.skipUnless(six.PY2, "Python 2 only -- Python 3 doesn't have longs.")
|
@unittest.skipUnless(six.PY2, "Python 2 only -- Python 3 doesn't have longs.")
|
||||||
def test_slicing_works_with_longs(self):
|
def test_slicing_works_with_longs(self):
|
||||||
self.assertEqual(self.get_ordered_articles()[long(0)].name, 'Article 1')
|
# NOQA: long undefined on PY3
|
||||||
self.assertQuerysetEqual(self.get_ordered_articles()[long(1):long(3)],
|
self.assertEqual(self.get_ordered_articles()[long(0)].name, 'Article 1') # NOQA
|
||||||
|
self.assertQuerysetEqual(self.get_ordered_articles()[long(1):long(3)], # NOQA
|
||||||
["<Article: Article 2>", "<Article: Article 3>"])
|
["<Article: Article 2>", "<Article: Article 3>"])
|
||||||
self.assertQuerysetEqual(self.get_ordered_articles()[::long(2)],
|
self.assertQuerysetEqual(self.get_ordered_articles()[::long(2)], # NOQA
|
||||||
["<Article: Article 1>",
|
["<Article: Article 1>",
|
||||||
"<Article: Article 3>",
|
"<Article: Article 3>",
|
||||||
"<Article: Article 5>",
|
"<Article: Article 5>",
|
||||||
"<Article: Article 7>"])
|
"<Article: Article 7>"])
|
||||||
|
|
||||||
# And can be mixed with ints.
|
# And can be mixed with ints.
|
||||||
self.assertQuerysetEqual(self.get_ordered_articles()[1:long(3)],
|
self.assertQuerysetEqual(self.get_ordered_articles()[1:long(3)], # NOQA
|
||||||
["<Article: Article 2>", "<Article: Article 3>"])
|
["<Article: Article 2>", "<Article: Article 3>"])
|
||||||
|
|
||||||
def test_slicing_without_step_is_lazy(self):
|
def test_slicing_without_step_is_lazy(self):
|
||||||
|
|
Loading…
Reference in New Issue