modernize icon indicating copy to clipboard operation
modernize copied to clipboard

Fixers on command line not working

Open danpalmer opened this issue 7 years ago • 3 comments

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.

danpalmer avatar Aug 02 '16 16:08 danpalmer

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.

takluyver avatar Aug 02 '16 17:08 takluyver

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).

daira avatar Aug 09 '16 08:08 daira

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?

danpalmer avatar Aug 09 '16 08:08 danpalmer