def calculate_unaryop(self, node, next_node):
        """Create new node for unaryop"""
        position = (next_node.first_line, next_node.first_col + 1)
        possible = []
        for ch in OPERATORS[node.__class__]:
            try:
                pos = self.operators[ch].find_previous(position)
                if pos[1] < position:
                    possible.append(pos)
            except KeyError:
                pass

        return NodeWithPosition(
            *min(possible, key=lambda x: tuple(map(sub, position, x[0])))
        )
def calculate_unaryop ( self , node , next_node ) : position = ( next_node . first_line , next_node . first_col + 1 ) possible = [ ] for ch in OPERATORS [ node . __class__ ] : try : pos = self . operators [ ch ] . find_previous ( position ) if pos [ 1 ] < position : possible . append ( pos ) except KeyError : pass return NodeWithPosition ( * min ( possible , key = lambda x : tuple ( map ( sub , position , x [ 0 ] ) ) ) )
Create new node for unaryop