mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-05 02:03:09 +00:00
Look inside try/except for requests imports
This commit is contained in:
@@ -204,6 +204,18 @@ class ModuleValidator(Validator):
|
||||
'should use '
|
||||
'ansible.module_utils.urls '
|
||||
'instead')
|
||||
elif isinstance(child, ast.TryExcept):
|
||||
bodies = child.body
|
||||
for handler in child.handlers:
|
||||
bodies.extend(handler.body)
|
||||
for grandchild in bodies:
|
||||
if isinstance(grandchild, ast.Import):
|
||||
for name in grandchild.names:
|
||||
if name.name == 'requests':
|
||||
self.errors.append('requests import found, '
|
||||
'should use '
|
||||
'ansible.module_utils.urls '
|
||||
'instead')
|
||||
|
||||
def _find_module_utils(self, main):
|
||||
linenos = []
|
||||
|
||||
Reference in New Issue
Block a user