mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Enable pylint rules and fix exposed bugs. (#47219)
* Resolve invalid-unary-operand-type. * Resolve raising-format-tuple. * Resolve stop-iteration-return. * Use disable comment instead of fixing logic. The affected line in _find_address_range will only fail on Python 3.7 and later if the function is called with an empty address list. As an internal method it is never called in this way, making it a non-issue for use via public methods. Using a comment to disable the rule in favor of an ignore.txt entry since there are no plans to change the logic in the code itself. This will also prevent any potential future issues being added in other parts of the code when updating it based on upstream changes.
This commit is contained in:
@@ -346,7 +346,7 @@ def _find_address_range(addresses):
|
||||
|
||||
"""
|
||||
it = iter(addresses)
|
||||
first = last = next(it)
|
||||
first = last = next(it) # pylint: disable=stop-iteration-return
|
||||
for ip in it:
|
||||
if ip._ip != last._ip + 1:
|
||||
yield first, last
|
||||
|
||||
@@ -81,7 +81,7 @@ except ImportError:
|
||||
if node.name in _safe_names:
|
||||
return _safe_names[node.name]
|
||||
elif isinstance(node, ast.UnarySub):
|
||||
return -_convert(node.expr)
|
||||
return -_convert(node.expr) # pylint: disable=invalid-unary-operand-type
|
||||
raise ValueError('malformed string')
|
||||
return _convert(node_or_string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user