The next leaf node might not be a direct grand child when nesting
operators. This patches introduces a function `replace_first_leaf` that
replaces the correct leaf.
A leading `+`/`-` is part of the float literal if there is no space in
between (in which case it becomes a call). This patch fixes the regexes
to handle this for float parsing.
It is a bit weird to not be consistent and put spaces around all
operators, but most people would agree that using no spaces for `:` and
`^` look better.
`for`-loop nodes are of kind K"=" even when using `in`. This patch fixes
the predicate for `spaces_around_assignments` to include K"in" as an
option. Note that when using `in` spaces are required, but the pass
is still useful to remove spaces when there are more than one.
This adds a pass which adds a single space between operators, for
example `a+b` -> `a + b` and `a==b` -> `a == b`. Note that comparison
chains are still left untouched (`a == b == c`) and is a todo.
Sometimes there is a need to check the kind (possibly more) of previous
and next siblings in order to decide on formatting. This patch keeps
track of this in the Context.
This is used for replacing trailing whitespace from consecutive
NewlineWs nodes since sometimes the whitespace is after the LF.