We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac21860 commit a8c69fdCopy full SHA for a8c69fd
libmodernize/fixes/fix_import.py
@@ -1,6 +1,7 @@
1
from __future__ import absolute_import
2
3
from lib2to3.fixes import fix_import
4
+from lib2to3.fixer_util import syms
5
import libmodernize
6
7
@@ -11,8 +12,12 @@ class FixImport(fix_import.FixImport):
11
12
run_order = 1
13
14
def transform(self, node, results):
- results = super(FixImport, self).transform(node, results)
15
- if results is None:
+ if self.skip:
16
return
17
+ # We're not interested in __future__ imports here
18
+ if node.type == syms.import_from and results['imp'].value == '__future__':
19
+ return
20
+
21
+ # If there are any non-future imports, add absolute_import
22
libmodernize.add_future(node, 'absolute_import')
- return results
23
+ return super(FixImport, self).transform(node, results)
0 commit comments