Add code to allow from __future__ in docs-only modules

This commit is contained in:
Toshio Kuratomi 2017-07-28 20:08:29 -07:00
parent 8b7db55a94
commit 6f69cd4501

View file

@ -285,9 +285,18 @@ class ModuleValidator(Validator):
return False
def _just_docs(self):
"""Module can contain just docs and from __future__ boilerplate
"""
try:
for child in self.ast.body:
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 True
except AttributeError: