1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Look inside try/except for requests imports

This commit is contained in:
Matt Martz 2016-02-29 09:24:09 -06:00 committed by John Barker
parent 28774875b4
commit 10d683a962

View file

@ -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 = []