Ternary expression is split strangely.
With yapf 0.29.0, google style, I'm getting this:
next_playable_unit = self._next_playable_unit_callback(
None if self._prepared_playable_unit_id is None else self.
_playable_units[self._prepared_playable_unit_id])
I was expecting something more like this:
next_playable_unit = self._next_playable_unit_callback(
None if self._prepared_playable_unit_id is None
else self._playable_units[self._prepared_playable_unit_id])
I am doing some tryouts and I aggree with you. It seems Yapf is very reluctant to split before the else clause. I just have a simple but too long ternary assignment which is always split before the if clause:
message = "Hard delete." if my_long_condition_variable == 'my_long_condition_name' else ''
Yapf (with the help of the surrounding parentheses) reformats this to:
message = ("Hard delete."
if my_long_condition_variable == 'my_long_condition_name' else '')
But I would expect it to split before the else, just like you (it seems more natural to a human being, doesn't it?). The result would be:
message = ("Hard delete." if my_long_condition_variable == 'my_long_condition_name'
else '')
YAPF tries to keep tightly-bound regions together. In this case, it sees the if - then - else bit as being more tightly bound. This is arguably wrong,...