mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add code to allow from __future__ in docs-only modules
This commit is contained in:
parent
8b7db55a94
commit
6f69cd4501
1 changed files with 9 additions and 0 deletions
|
@ -285,9 +285,18 @@ class ModuleValidator(Validator):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _just_docs(self):
|
def _just_docs(self):
|
||||||
|
"""Module can contain just docs and from __future__ boilerplate
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
for child in self.ast.body:
|
for child in self.ast.body:
|
||||||
if not isinstance(child, ast.Assign):
|
if not isinstance(child, ast.Assign):
|
||||||
|
# allowed from __future__ imports
|
||||||
|
if isinstance(child, ast.ImportFrom) and child.module == '__future__':
|
||||||
|
for future_import in child.names:
|
||||||
|
if future_import.name not in self.WHITELIST_FUTURE_IMPORTS:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
continue
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Loading…
Reference in a new issue