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:
parent
28774875b4
commit
10d683a962
1 changed files with 12 additions and 0 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Reference in a new issue