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

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

Open
jeremysalwen opened this issue Oct 27, 2016 · 5 comments

Comments

@jeremysalwen
Copy link

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
Copy link
Owner

hayd commented Oct 28, 2016

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

@jeremysalwen
Copy link
Author

Any updates on this?

@infinitewarp
Copy link

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 #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
Copy link
Owner

hayd commented Dec 28, 2016

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
Copy link

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

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

4 participants