This sort of thing is why we would recommend against using anvil.call() these days. The modern Javascript interop (anvil.js and friends) means you can make Python functions available to Javascript directly.
Even if you want to be able to do a global call from JS to Python, you can do something like:
from anvil.js import window
def my_function(args):
...
window.my_function = my_function
…and then from JS, you now have a global my_function() you can call from anywhere!