
Your Python function takes a filename and **kwargs. But this raises an error, since “filename” is passed twice:
myfunc('outfile.txt', filename='abcd', x=100)
Solution: Set filename to be positional only:
def myfunc(filename, /, **kwargs):
Now any keyword argument works!
