mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 14:21:26 -07: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 '
|
'should use '
|
||||||
'ansible.module_utils.urls '
|
'ansible.module_utils.urls '
|
||||||
'instead')
|
'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):
|
def _find_module_utils(self, main):
|
||||||
linenos = []
|
linenos = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue