From 6f69cd4501cec1e3d56dac1f6eed90fb10f57eb8 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 28 Jul 2017 20:08:29 -0700 Subject: [PATCH] Add code to allow from __future__ in docs-only modules --- test/sanity/validate-modules/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/sanity/validate-modules/main.py b/test/sanity/validate-modules/main.py index 0810d6de53..8c19630646 100755 --- a/test/sanity/validate-modules/main.py +++ b/test/sanity/validate-modules/main.py @@ -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: