-
Notifications
You must be signed in to change notification settings - Fork 891
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
yapf with --style=pep8 puts imports on one line even if that breaks the character limit #18
Comments
Confirmed in master. |
YAPF won't do much with this for these reasons:
Both (2) and (3) are more along the lines of a refactoring tool (see the rope library). I could see this as a 2to3 fixer in a "contrib" directory. But even that's iffy... |
Ah, so an important detail that you wouldn't know because I completely failed to mention it, sorry, is that the problem here is that yapf is doing something! My objection isn't that yapf isn't fixing it, it's that yapf is breaking it in the first place. The provided example was originally:
Which is perfectly valid formatting, and yapf produced the single line variant. |
Incidentally, I already handle getting imports correct and sorted using the isort library. In my current work flow I run that before pyformat, but I could change that to solve this problem by running yapf before isort. It's just a shame to introduce errors that weren't present in the original source. |
Well, as I mentioned we intentionally don't use backslash-newlines. IMHO, they are a blight on proper code. Note that the import statement above goes against the PEP 8 style guide (https://www.python.org/dev/peps/pep-0008/#imports). Also, I believe that import statements are immune from pylint warnings about going over 80 columns. |
Consider e.g.
(there's nothing special about this being a from future import, it's just an example of a long import from my project)
This import line is more than 82 characters but yapf puts it all on one line. It does this even if the code was originally broken across multiple lines.
The text was updated successfully, but these errors were encountered: