From 14c199bb7ee187e67b3dac216e71695c5090604e Mon Sep 17 00:00:00 2001 From: Torsten Marek Date: Fri, 25 Apr 2014 23:31:38 +0200 Subject: Use Module.future_imports for detecting if print is a builtin. --- checkers/format.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/checkers/format.py b/checkers/format.py index eedce59..8b73049 100644 --- a/checkers/format.py +++ b/checkers/format.py @@ -474,10 +474,8 @@ class FormatChecker(BaseTokenChecker): def process_module(self, module): self._keywords_with_parens = set() - for node in module.body: - if (isinstance(node, nodes.From) and node.modname == '__future__' - and any(name == 'print_function' for name, _ in node.names)): - self._keywords_with_parens.add('print') + if 'print_function' in module.future_imports: + self._keywords_with_parens.add('print') def _check_keyword_parentheses(self, tokens, start): """Check that there are not unnecessary parens after a keyword. -- cgit v1.2.1