Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Duplicate __future__ imports #13

Closed

Description

@jonashaag

t.py

print 'a'
print 'b'

behavior

$ python2 modernize.py t.py
[...]
--- t.py        (original)
+++ t.py        (refactored)
@@ -1,2 +1,4 @@
-print 'a'
-print 'b'
+from __future__ import print_function
+from __future__ import print_function
+print('a')
+print('b')
[...]

inserts __future__ import for every print statement.

Activity

  1. euresti commented on Apr 26, 2014

    @euresti

    I think this patch fixes it

    diff --git a/libmodernize/__init__.py b/libmodernize/__init__.py
    index 5b938c9..34de45b 100644
    --- a/libmodernize/__init__.py
    +++ b/libmodernize/__init__.py
    @@ -12,7 +12,7 @@ def check_future_import(node):
         node = node.children[0]
         # now node is the import_from node
         if not (node.type == syms.import_from and
    -            node.type == token.NAME and
    +            node.children[1].type == token.NAME and
                 node.children[1].value == u'__future__'):
             return set()
         node = node.children[3]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions