mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-26 21:33:05 +00:00
pylint: Fix warning 'unnecessary "else" after "return"'
Recent pylint versions warn against the use of an 'else' in a 'try-except' block if using a 'return' on the 'except' part is is the idom used by ansible-freeipa when retrieving IPA data objects. This change removes the usage of the 'else:' in such cases, and modify the templates so that new modules do not have the same issue in the future.
This commit is contained in:
@@ -62,8 +62,7 @@ def get_plugins_from_playbook(playbook):
|
||||
return []
|
||||
except yaml.parser.ParserError: # If not a YAML/JSON file.
|
||||
return []
|
||||
else:
|
||||
return data if data else []
|
||||
return data if data else []
|
||||
|
||||
data = load_playbook(playbook)
|
||||
task_blocks = [t.get("tasks", []) if "tasks" in t else [] for t in data]
|
||||
|
||||
@@ -127,8 +127,7 @@ def find_$name(module, name):
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# An exception is raised if $name name is not found.
|
||||
return None
|
||||
else:
|
||||
return _result["result"]
|
||||
return _result["result"]
|
||||
|
||||
|
||||
def gen_args(PARAMETER1):
|
||||
|
||||
@@ -103,8 +103,7 @@ def find_$name(module, name):
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# An exception is raised if $name name is not found.
|
||||
return None
|
||||
else:
|
||||
return _result["result"]
|
||||
return _result["result"]
|
||||
|
||||
|
||||
def gen_args(PARAMETER1, PARAMETER2):
|
||||
|
||||
Reference in New Issue
Block a user