Hacker News new | ask | show | jobs
by Fuzzwah 4095 days ago
I've got a python project where I've been pretty naughty with long lines containing sql queries.

I found that running this tool over it resulted in some strange new lines.

For example, this was my old hideously long line:

query_qual = "INSERT OR REPLACE INTO Qualifying (poleid, seasonid, race_week_num, carclassid, pole) values (%s%s, %s, %s, %s, %s)" % (race[u'seasonid'], race[u'race_week_num'], race[u'seasonid'], race[u'race_week_num'], race[u'carclassid'], pole)

Changed to this:

query_qual = "INSERT OR REPLACE INTO Qualifying (poleid, seasonid, race_week_num, carclassid, pole) values (%s%s, %s, %s, %s, %s)" % ( race[u'seasonid'], race[u'race_week_num'], race[ u'seasonid' ], race[u'race_week_num'], race[u'carclassid'], pole)

4 comments

To my eye, HN has rendered them identically. You can preserve literal whitespace on HN by indenting by two spaces (and a newline to separate the code formatting from ordinary text).

  it appears     like  this
newlines need to be escaped somehow (two newlines seems to do it), otherwise they are combined into the same line:

Every word in this sentence was entered on a different line.

You could try set the line length penalty so something really high. That would probably sort things out.
Feel free to submit a Github issue for yapf