Relative Content

Tag Archive for pythonpython-3.xargparse

How to explicitely list allowed keyword arguments in python for IDE support?

I’m using
ArgumentParser
in python and giving users the option to add their own functions to my script. For that, I’m giving them a function that generates data that gets used in argparse’s
add_argument()
function. I noticed that add_argument’s signature is
add_argument(self, *args, **kwargs)
but when looking at the documentation in vscode I can see all the different arguments it can get (action, nargs, const, default, etc.). How does python do it? As far as I know when you give the user **kwargs it is shown as **kwargs and that’s it.