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:
Rafael Guterres Jeffman
2023-07-12 18:01:59 -03:00
parent fd1352ad7e
commit 24efad73fa
19 changed files with 20 additions and 40 deletions

View File

@@ -358,8 +358,7 @@ def get_netbios_name(module):
_result = module.ipa_command_no_name("trustconfig_show", {"all": True})
except Exception: # pylint: disable=broad-except
return None
else:
return _result["result"]["ipantflatname"][0]
return _result["result"]["ipantflatname"][0]
def is_enable_sid(module):