question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yapf (facebook style) loves to make a two-step reformat of over-long line

See original GitHub issue

YAPF loves to make two steps if run twice in fixing this:

# last character is column 87 with our indent
self.assertEqual(result.reason_not_added, "current preflight is still running")

becomes

self.assertEqual(result.reason_not_added,
                 "current preflight is still running")

next run it becomes

self.assertEqual(
    result.reason_not_added, "current preflight is still running"
)

Now, I like the last option best, and it’s what we want, but the fact we take consistently two steps to get there is a surprise. I’m not sure why it prefers the intermediate form once, but it happens often enough to feel “routine”.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ambvcommented, May 16, 2016

This problem is inherent to YAPF’s rules that depend on the “current relative line location”. After a single reformatting that relative location might change, in which case it will have different penalties assigned. I haven’t got time to really work on this before, you’re probably have to wait until PyCon for me to get to this during sprints.

0reactions
ppolewiczcommented, May 18, 2016

I confirm that it now works correctly for both my code and the example supplied by @daniel-pittman.

Please release to pypi.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
yapf (facebook style) loves to make a two-step reformat of over-long line.
Read more >
How to use yapf (or black) in VSCode - Stack Overflow
According to the YAPF documentation: YAPF will search for the formatting style in the following manner: Specified on the command line >> VS...
Read more >
Software Engineering at Google
arguments for adopting best practices like testing, knowledge sharing, and ... and do a line-by-line “readability review” of their first major code commit....
Read more >
Auto formatters for Python
You can see that yapf (Facebook) and black are trying to convert the code to multi-line brackets while the rest do not do...
Read more >
Software Engineering at Google - DOKUMEN.PUB
How an organization makes decisions, based on the lessons of Time and Change ... A book like this would not be possible without...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found