pylint: fix some refactor recommendations
openstack_dashboard/dashboards/project/security_groups/forms.py:393:13: R1714: Consider merging these comparisons with "in" to "rule_menu in ('tcp', 'udp')" (consider-using-in) openstack_dashboard/api/rest/json_encoder.py:61:15: R0124: Redundant comparison - o != o (comparison-with-itself) openstack_dashboard/api/keystone.py:904:15: R1714: Consider merging these comparisons with "in" to 'default in (role.id, role.name)' (consider-using-in) horizon/templatetags/truncate_filter.py:30:7: R1716: Simplify chained comparison between the operands (chained-comparison) Change-Id: I6cf8602f88c4027ff12aaa4ea5a9f2069ae2e2a6
This commit is contained in:
parent
c9536342c2
commit
7c585e2643
@ -56,9 +56,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
|
||||
|
@ -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:
|
||||
|
@ -899,7 +899,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
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user