How to handle *args in python docstring?

153 Views Asked by At

I have a some functions in my code that are specified like this: def myfunction(self, *args, **kwargs):

I need these functions to be a bit flexible on how they are called such that they will still run correctly even if some extra args or kwargs are passed in, however, each function has a specification on what args are expected/used. I would like to document those specifications in the docstring. I am currently using Google-Style docstring format. I am able to specify the **kwargs without any problem like this:

keyword Args:
    raw_args (str): raw string of arguments
    replace (bool): replace mode

However, for *args, I would like to do something similar, but I can't figure out how to do that in a way that renders nicely in pycharm. For example, I tried this:

Args:
    args[0] (str): filename of the python macro
    args[1] (str): character to insert

This does not render at all. I've also tried this:

Args:
    *args:
        args[0] (str): filename of the python macro
        args[1] (str): character to insert

This renders, but just throws everything under *args into a single line, which is not good. Is there a better way to do this? I'm open to potentially switch to a different docstring format if that would solve my problem.

0

There are 0 best solutions below