Search code examples
python-2.7docstring

Proper Google docstring for lists


I've been using the Google Docstring format described here but I'm wondering if there is an agreed upon method for documenting lists of a known type.

I've been using

def function(a_list)
    """

    Args:
        a_list (list[dict]): a list of dictionaries
    """
    ...

Is this correct?


Solution

  • Given the advances in type hinting that didn't exist when I first asked this question I would now defer to that style:

    from typing import List
    
    def function(a_list: List[dict])
        """
    
        Args:
            a_list (List[dict]): a list of dictionaries
        """
        ...