Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Futurize to add __future__ imports breaks pylint directives #588

Open
amethystmarie opened this issue Jul 7, 2021 · 0 comments
Open

Futurize to add __future__ imports breaks pylint directives #588

amethystmarie opened this issue Jul 7, 2021 · 0 comments

Comments

@amethystmarie
Copy link

When running the futurize fixer libfuturize.fixes.fix_unicode_literals_import on a file with a pylint directive, the import is added prior to the pylint directive, which causes them to be ignored. This is true of all directives that don't match the specific regexes of encoding, docstrings and shebang that the future_import method checks for.

def future_import(feature, node):

Before:

# pylint: disable=import-error,invalid-name

import path
import system

Run: futurize --write --fix=libfuturize.fixes.fix_unicode_literals_import

After:

from __future__ import unicode_literals

# pylint: disable=import-error,invalid-name

import path
import system

If it skipped to the first non-commented, non-docstring line before inserting anything, it would fix this and any other directives that haven't been accounted for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant