Merge "pylint: fix some refactor recommendations"

This commit is contained in:
Zuul 2019-01-16 17:57:12 +00:00 committed by Gerrit Code Review
commit 60dd57655b
5 changed files with 6 additions and 5 deletions

View File

@ -48,9 +48,6 @@ disable=
unused-variable,
wrong-import-order, # TODO
# "R" Refactor recommendations
chained-comparison,
comparison-with-itself,
consider-using-in,
cyclic-import, # TODO
duplicate-code,
inconsistent-return-statements, # TODO

View File

@ -27,6 +27,7 @@ register = template.Library()
@register.filter("truncate")
def truncate(value, size):
# pylint: disable=chained-comparison
if len(value) > size and size > 3:
return value[0:(size - 3)] + '...'
else:

View File

@ -901,7 +901,7 @@ def get_default_role(request):
roles = []
exceptions.handle(request)
for role in roles:
if role.id == default or role.name == default:
if default in (role.id, role.name):
DEFAULT_ROLE = role
break
return DEFAULT_ROLE

View File

@ -58,6 +58,9 @@ class NaNJSONEncoder(json.JSONEncoder):
# and/or platform-specific, so do tests which don't depend on the
# internals.
# NOTE: In Python, NaN == NaN returns False and it can be used
# to detect NaN.
# pylint: disable=comparison-with-itself
if o != o:
text = self.nan_str
elif o == _inf:

View File

@ -390,7 +390,7 @@ class AddRule(forms.SelfHandlingForm):
rule_menu = cleaned_data.get('rule_menu')
if rule_menu == 'icmp':
self._clean_rule_icmp(cleaned_data, rule_menu)
elif rule_menu == 'tcp' or rule_menu == 'udp':
elif rule_menu in ('tcp', 'udp'):
self._clean_rule_tcp_udp(cleaned_data, rule_menu)
elif rule_menu == 'custom':
self._clean_rule_custom(cleaned_data, rule_menu)