mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
Add checks for from module_utils import * (#21800)
This commit is contained in:
@@ -364,6 +364,19 @@ class ModuleValidator(Validator):
|
||||
linenos.append(child.lineno)
|
||||
|
||||
for name in child.names:
|
||||
if ('module_utils' in getattr(child, 'module', '') and
|
||||
isinstance(name, ast.alias) and
|
||||
name.name == '*'):
|
||||
msg = (
|
||||
208,
|
||||
('module_utils imports should import specific '
|
||||
'components, not "*". line %d' % child.lineno)
|
||||
)
|
||||
if self._is_new_module():
|
||||
self.errors.append(msg)
|
||||
else:
|
||||
self.warnings.append(msg)
|
||||
|
||||
if (isinstance(name, ast.alias) and
|
||||
name.name == 'basic'):
|
||||
found_basic = True
|
||||
|
||||
Reference in New Issue
Block a user