Skip to content

Adds import inside class when class starts at top of file after encoding comment #432

Closed

Description

$ cat test.py
# -*- coding:utf-8 -*-
class Foo(object):

    def bar(self):
        return 'baz'
$ isort --diff -a 'from __future__ import absolute_import' test.py
--- /Users/adamj/Documents/Projects/pyticketswitch/test.py:before   2016-04-29 15:32:17
+++ /Users/adamj/Documents/Projects/pyticketswitch/test.py:after    2016-04-29 15:32:36.902051
@@ -1,5 +1,6 @@
 # -*- coding:utf-8 -*-
 class Foo(object):
+from __future__ import absolute_import

     def bar(self):
         return 'baz'

This doesn't happen if there is no encoding comment at the start of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions