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

Incorrect changes on code using both map and itertools.imap #175

Open
jbradaric opened this issue Feb 14, 2019 · 0 comments
Open

Incorrect changes on code using both map and itertools.imap #175

jbradaric opened this issue Feb 14, 2019 · 0 comments

Comments

@jbradaric
Copy link

Running python-modernize on code using both map and itertools.imap produces the wrong code.
For example, running python-modernize on the following code

from itertools import imap

def add_1(x):
    return x + 1

assert isinstance(map(add_1, [1, 2, 3]), list)
assert not isinstance(imap(add_1, [1, 2, 3]), list)

produces non-working code. python-modernize doesn't change map(add_1, [1, 2, 3]) to list(map(add_1, [1, 2, 3])) as it should.
The issue seems to be caused by libmodernize.fixes.fix_itertools_imports_six fixer running before libmodernize.fixes.fix_map by default. Changing the run order of FixItertoolsImportsSix class to 6 modifies the code correctly.

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

No branches or pull requests

2 participants