mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-25 05:23:58 -07: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…
	
	Add table
		Add a link
		
	
		Reference in a new issue