mirrors: silence flake8 E721

This commit is contained in:
Jelle van der Waa 2023-08-10 10:08:45 +02:00 committed by Jelle van der Waa
parent 9e4df5f0f3
commit 6883cbea24
2 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@
@register.filter @register.filter
def duration(value): def duration(value):
if not value and type(value) != timedelta: if not value or not isinstance(value, timedelta):
return u'' return u''
# does not take microseconds into account # does not take microseconds into account
total_secs = value.seconds + value.days * 24 * 3600 total_secs = value.seconds + value.days * 24 * 3600
@ -17,7 +17,7 @@ def duration(value):
@register.filter @register.filter
def hours(value): def hours(value):
if not value and type(value) != timedelta: if not value or not isinstance(value, timedelta):
return u'' return u''
# does not take microseconds into account # does not take microseconds into account
total_secs = value.seconds + value.days * 24 * 3600 total_secs = value.seconds + value.days * 24 * 3600
@ -30,7 +30,7 @@ def hours(value):
@register.filter @register.filter
def percentage(value, arg=1): def percentage(value, arg=1):
if not value and type(value) != float: if not value or not isinstance(value, float):
return u'' return u''
new_val = value * 100.0 new_val = value * 100.0
return '%.*f%%' % (arg, new_val) return '%.*f%%' % (arg, new_val)

View File

@ -22,5 +22,5 @@ def test_hours():
def test_percentage(): def test_percentage():
assert percentage(None) == '' assert percentage(None) == ''
assert percentage(10) == '1000.0%' assert percentage(10.0) == '1000.0%'
assert percentage(10, 2) == '1000.00%' assert percentage(10.0, 2) == '1000.00%'