So we have this line:
temp['description'] = current_transaction['Description'] + ' ' + nearest_duplicate['Description']
when running yapf using the google styling, I get:
temp[
'description'] = current_transaction['Description'] + ' ' + nearest_duplicate['Description']
Which A) it ugly and B) it reduces the max line length by a whole 1 space (going from 101 to 100). Whoop-de-do.
I'd much rather it just stay in the first condition. It looks cleaner and is much easier to understand what's going on.
Similar issue here. This:
last_good_param_path = event['redundancy_check_results']['last_good_param_path']
is turning into this:
last_good_param_path = event['redundancy_check_results'][
'last_good_param_path']
when I run
yapf -i -r -p .
Is this intentional? Looks worse in my opinion.
EDIT: The original line actually does go over PEP8 column limit by one character. 80 > 79
I hope it's not intentional. Because it just makes it more difficult to read. I'm pretty sure mine goes over the PEP8 limit, but it really should come out something like this:
temp['description'] = current_transaction['Description'] + ' ' +
nearest_duplicate['Description']
Found another oddity. Also think I figured out why it's doing it.
I had the line:
self.ar = (self.L * math.tan(math.radians(self.phi)) + self.r)**2 / self.r**2
which turned into this:
self.ar = (
self.L * math.tan(math.radians(self.phi)) + self.r)**2 / self.r**2
I think yapf is designed to leave a (, {, or [ at the end of each line in a multi-line statement. That way, it's more obvious that the line continues.
I don't necessarily agree with that, but I can understand it at least. It can make some statements more difficult to read, but ensures that the reader knows of the line continuation.
@dylanmroweFS Also, looking back at your original code, it does actually go over the PEP8 limit. If you look at the style definition for PEP8, the column limit is set to 79 and your line has 80 characters.
Edit: Also, PEP8 itself says 79.
@u2berggeist Ah. Thanks for checking, sorry I didn't do that. It looked short enough that I just assumed. 馃槥 Good to know that there's at least a valid reason for the line break.
The issues here have to do with the column limit and the fact that Python cannot have expressions span multiple lines without them being contained within parentheses or if a \ is added. YAPF doesn't allow the line to go over the column limit if there's a way to split it so that it won't. As for the initial issue, yapf now formats it like this:
temp['description'] = current_transaction[
'Description'] + ' ' + nearest_duplicate['Description']
which is a bit better. If you add parentheses around the right hand side, it generates this:
temp['description'] = (current_transaction['Description'] + ' ' +
nearest_duplicate['Description'])
(Note that yapf won't add parentheses for you.)
So basically all of this is intentional, though at the time it wasn't all that great (it's better now).