Skip to content

Add fixer for itertools #466

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

Merged
merged 2 commits into from
May 8, 2019
Merged

Add fixer for itertools #466

merged 2 commits into from
May 8, 2019

Conversation

ucodery
Copy link
Contributor

@ucodery ucodery commented May 8, 2019

Use of ifilter, imap, and izip as generator forms of PY2 builtins are replaced
with future.builtins versions that are always generators

This fixes issue #424

ucodery added 2 commits May 8, 2019 14:25
Use of ifilter, imap, and izip as generator forms of PY2 builtins are replaced
with future.builtins versions that are always generators
@jmadler jmadler merged commit e12549c into PythonCharmers:master May 8, 2019
@jmadler
Copy link
Contributor

jmadler commented May 8, 2019

Thanks for your help! :)

@ucodery
Copy link
Contributor Author

ucodery commented May 8, 2019

I am not sure why issue #424 was opened in the first place. This worked fine before this merge.

from itertools import imap

print imap(pow, range(1, 10, 3), range(1,4))
(python-future) MBP-jpaige% python -m futurize ./test.py
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored ./test.py
--- ./test.py	(original)
+++ ./test.py	(refactored)
@@ -1,3 +1,6 @@
-from itertools import imap
+from __future__ import print_function
+from builtins import map
+from builtins import range

-print imap(pow, range(1, 10, 3), range(1,4))
+
+print(list(map(pow, list(range(1, 10, 3)), list(range(1,4)))))
RefactoringTool: Files that need to be modified:
RefactoringTool: ./test.py

Sorry about this, but I think this change should be backed out. The same logic was already implemented in src/future/moves/itertools.py

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

Successfully merging this pull request may close these issues.

2 participants