Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Google docstring format: more than one type for argument?

I am using Google-style python docstring format. There's one function, and the input parameter could be dict, list, or string. What is the format of multiple data type in docstring?

Like

Args:
    input (str, list, dict): input of this function
like image 960
user19881219 Avatar asked Nov 20 '18 08:11

user19881219


1 Answers

As it is stated in the Sphinx 1.5 documentation describing this style of formatting, PEP 484 type annotations are supported.

PEP 484 specifies the Union type as appropriate for a situation where you have a limited set of accepted types for an argument. In your example it will be:

Args:
    input (Union[str, list, dict]): input of this function
like image 155
arudzinska Avatar answered Nov 15 '22 00:11

arudzinska