mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -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
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
|||
|
||||
from collections import MutableMapping, MutableSet, MutableSequence
|
||||
|
||||
from ansible.errors import AnsibleAssertionError
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.parsing.plugin_docs import read_docstring
|
||||
from ansible.parsing.yaml.loader import AnsibleLoader
|
||||
|
@ -59,7 +60,8 @@ def add_fragments(doc, filename):
|
|||
fragment_name, fragment_var = fragment_slug, 'DOCUMENTATION'
|
||||
|
||||
fragment_class = fragment_loader.get(fragment_name)
|
||||
assert fragment_class is not None
|
||||
if fragment_class is None:
|
||||
raise AnsibleAssertionError('fragment_class is None')
|
||||
|
||||
fragment_yaml = getattr(fragment_class, fragment_var, '{}')
|
||||
fragment = AnsibleLoader(fragment_yaml, file_name=filename).get_single_data()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue