-
I would like to control the whitespace around all binary operators. So far, I got def leave_Add(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_Subtract(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_Multiply(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_Divide(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_Modulo(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_Power(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0)
def leave_MatrixMultiply(self, orig_node, updated_node):
return updated_node.with_changes(whitespace_before=s0, whitespace_after=s0) which works well. It seems a little repetetive though, and perhaps I forgot an operation. Is there a way to shorten this? |
Beta Was this translation helpful? Give feedback.
Answered by
nschloe
Dec 30, 2022
Replies: 1 comment
-
I found class WhitespaceRemover2(m.MatcherDecoratableTransformer):
@m.leave(
m.Add()
| m.Subtract()
| m.Multiply()
| m.Divide()
| m.Modulo()
| m.MatrixMultiply()
| m.Power()
)
def rm_space_around_operators(self, orig_node, updated_node):
return updated_node.with_changes(
whitespace_before=s0,
whitespace_after=s0,
) Perhaps this can be improved further. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nschloe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found
Perhaps this can be improved further.