hayd / pep8radius

PEP8 clean only the parts of the files touched since the last commit, a previous commit or (the merge-base of) a branch.
MIT License
183 stars 9 forks source link

pep8radius --yapf crashes with "AttributeError: 'tuple' object has no attribute 'splitlines'" #85

Open jeremysalwen opened 7 years ago

jeremysalwen commented 7 years ago

pep8radius 0.9.2

$ pip install --user --upgrade pep8radius
Requirement already up-to-date: pep8radius in /home/jeremysalwen/.local/lib/python2.7/site-packages
Requirement already up-to-date: autopep8>=1.0.4 in /home/jeremysalwen/.local/lib/python2.7/site-packages (from pep8radius)
Requirement already up-to-date: colorama in /home/jeremysalwen/.local/lib/python2.7/site-packages (from pep8radius)
Requirement already up-to-date: docformatter>=0.7 in /home/jeremysalwen/.local/lib/python2.7/site-packages (from pep8radius)
Requirement already up-to-date: yapf>=0.1.5 in /home/jeremysalwen/.local/lib/python2.7/site-packages (from pep8radius)
Requirement already up-to-date: pep8>=1.5.7 in /home/jeremysalwen/.local/lib/python2.7/site-packages (from autopep8>=1.0.4->pep8radius)
Requirement already up-to-date: untokenize in /home/jeremysalwen/.local/lib/python2.7/site-packages (from docformatter>=0.7->pep8radius)
$pep8radius --yapf
Traceback (most recent call last):
  File "/home/jeremysalwen/.local/bin/pep8radius", line 11, in <module>
    sys.exit(_main())
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/main.py", line 275, in _main
    return sys.exit(main(args=args, vc=vc, cwd=cwd, apply_config=True))
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/main.py", line 82, in main
    r.fix()
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/radius.py", line 95, in fix
    p_diff = self.fix_file(file_name)
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/radius.py", line 129, in fix_file
    verbose=self.verbose, cwd=self.cwd)
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/radius.py", line 192, in fix_file
    return get_diff(original, fixed, file_name) if diff else fixed
  File "/home/jeremysalwen/.local/lib/python2.7/site-packages/pep8radius/diff.py", line 37, in get_diff
    original, fixed = original.splitlines(True), fixed.splitlines(True)
AttributeError: 'tuple' object has no attribute 'splitlines'
hayd commented 7 years ago

Thanks for sending this! I guess there has been an API change, will find a fix shortly. :)

jeremysalwen commented 7 years ago

Any updates on this?

infinitewarp commented 7 years ago

The current release version in pypi (0.9.2) hasn't been updated since 2015-04-13, but this issue with yapf was fixed by https://github.com/hayd/pep8radius/pull/82 on 2016-01-20.

If you want to try using the latest source version from github:

pip install --upgrade git+https://github.com/hayd/pep8radius.git

The -y/--yapf flag appears to work correctly for me following that upgrade. Beware that there might be other bugs lurking, as the travis-ci builds have been failing after the last several commits to master.

hayd commented 7 years ago

Sorry, I've let this slip by. I thought I'd pushed it out.

To fix the tests, I think need to remove the pep8radius option (at least remove it as the default) and move to just using yapf (or set pep8radius to an older version), pep8radius removed some (all?) of the line-to-line correction.

thundergolfer commented 6 years ago

Also can report this issue on the latest pip release. Get the following when running with --yapf

Traceback (most recent call last):
  File "./virtual_env/bin/pep8radius", line 11, in <module>
    sys.exit(_main())
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/site-packages/pep8radius/main.py", line 275, in _main
    return sys.exit(main(args=args, vc=vc, cwd=cwd, apply_config=True))
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/site-packages/pep8radius/main.py", line 82, in main
    r.fix()
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/site-packages/pep8radius/radius.py", line 95, in fix
    p_diff = self.fix_file(file_name)
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/site-packages/pep8radius/radius.py", line 129, in fix_file
    verbose=self.verbose, cwd=self.cwd)
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/site-packages/pep8radius/radius.py", line 190, in fix_file
    f.write(fixed)
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/codecs.py", line 706, in write
    return self.writer.write(data)
  File "/Users/jbelotti/Code/zendesk/content_cues/virtual_env/lib/python2.7/codecs.py", line 369, in write
    data, consumed = self.encode(object, self.errors)
TypeError: coercing to Unicode: need string or buffer, tuple found