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

Fixers on command line not working #139

Open
danpalmer opened this issue Aug 2, 2016 · 3 comments
Open

Fixers on command line not working #139

danpalmer opened this issue Aug 2, 2016 · 3 comments

Comments

@danpalmer
Copy link

When specifying fixers to exclude, these options appear to have no effect, and when specifying fixers to include, modernize fails with an import error:

Traceback (most recent call last):
  File "/Users/dan/.virtualenvs/python3port/bin/python-modernize", line 11, in <module>
    sys.exit(main())
  File "/Users/dan/.virtualenvs/python3port/lib/python2.7/site-packages/libmodernize/main.py", line 129, in main
    options.nobackups, not options.no_diffs)
  File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/lib2to3/main.py", line 63, in __init__
    super(StdoutRefactoringTool, self).__init__(fixers, options, explicit)
  File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/lib2to3/refactor.py", line 698, in __init__
    super(MultiprocessRefactoringTool, self).__init__(*args, **kwargs)
  File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/lib2to3/refactor.py", line 210, in __init__
    self.pre_order, self.post_order = self.get_fixers()
  File "/usr/local/var/pyenv/versions/2.7.11/lib/python2.7/lib2to3/refactor.py", line 245, in get_fixers
    mod = __import__(fix_mod_path, {}, {}, ["*"])
ImportError: No module named import

I am using version 0.5 installed into a new Python 2.7.11 virtualenv with nothing else, on OS X.

It looks like the issue is coming from lib2to3, but it's happening when I follow the documentation for modernize, so reporting it here.

@takluyver
Copy link
Contributor

I'm guessing you're using the short names. You need to use the full names as returned by python-modernize -l. E.g. libmodernize.fixes.fix_map. It would be a nice addition for it to work with short names, though.

@daira
Copy link
Contributor

daira commented Aug 9, 2016

Selecting fixers by short name is #27. If the reporter confirms that was the problem, we can close this (or perhaps make this ticket about improving the error reporting).

@danpalmer
Copy link
Author

Ah I'm sorry, I didn't find that bit in the documentation. Perhaps the line in the documentation about that could be emphasised. One way of doing this would be to make the section titles for the fixers the full dotted paths?

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

3 participants