mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-21 07:40:22 -07:00
Remove uses of assert in production code (#32079)
* Remove uses of assert in production code * Fix assertion * Add code smell test for assertions, currently limited to lib/ansible * Fix assertion * Add docs for no-assert * Remove new assert from enos * Fix assert in module_utils.connection
This commit is contained in:
parent
464ded80f5
commit
99d4f5bab4
38 changed files with 195 additions and 89 deletions
|
@ -65,7 +65,7 @@ import re
|
|||
from collections import MutableSequence
|
||||
from io import StringIO
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.errors import AnsibleError, AnsibleAssertionError
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
from ansible.module_utils._text import to_bytes, to_text
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
|
@ -129,7 +129,8 @@ class LookupModule(LookupBase):
|
|||
try:
|
||||
for param in params[1:]:
|
||||
name, value = param.split('=')
|
||||
assert(name in paramvals)
|
||||
if name not in paramvals:
|
||||
raise AnsibleAssertionError('%s not in paramvals' % name)
|
||||
paramvals[name] = value
|
||||
except (ValueError, AssertionError) as e:
|
||||
raise AnsibleError(e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue