I’d use functools partial here. I’ve not tried it but I think it will work.
from functools import partial
import anvil.js
dom_node = anvil.js.get_dom_node(my_component)
dom_node.addEventListener('contextmenu', partial(self.right_click, sender=my_component))
def right_click(self, e, sender):
e.preventDefault() # stop the default context menu
alert('right click')