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

View File

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