mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Check for requests imports. Fixes #12
This commit is contained in:
parent
61a49e0420
commit
69ec1e8e6a
1 changed files with 11 additions and 0 deletions
|
@ -196,6 +196,16 @@ class ModuleValidator(Validator):
|
|||
'already provided by '
|
||||
'ansible.module_utils.basic')
|
||||
|
||||
def _find_requests_import(self):
|
||||
for child in self.ast.body:
|
||||
if isinstance(child, ast.Import):
|
||||
for name in child.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 = []
|
||||
for child in self.ast.body:
|
||||
|
@ -401,6 +411,7 @@ class ModuleValidator(Validator):
|
|||
if self._python_module() and not self._just_docs():
|
||||
self._check_for_sys_exit()
|
||||
self._find_json_import()
|
||||
self._find_requests_import()
|
||||
main = self._find_main_call()
|
||||
self._find_module_utils(main)
|
||||
self._find_has_import()
|
||||
|
|
Loading…
Reference in a new issue