Skip to content

leave_AllBinaryOperators? match multiple classes #842

Answered by nschloe
nschloe asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nschloe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant