How to add python docstring for nested dictionary return type

Viewed 436

I'm trying to create a docstring for a return type Dictionary. The dictionary has Date->Dictionary key-value pairs. The nested Dictionary has 2 string->int key-value pairs and a string->Dictionary key-value pair

Current docstring looks like the following:

def func():
  """
  Some explanation of what my function does and explaining the return types

    Returns:
      a_dict(Dictionary)
        Key: date (Date)
        Value: another_dict(Dictionary)
          Key: 'foo' (str)
          Value: value (int) 
          Key: 'bar' (str)
          Value: value (int) 
          Key: 'qaz' (str)
          Value: third_dict (Dictionary of str:int)


 """

However, this is looking a lot messier and complicated than I would like.

What my return looks like

{
  datetime.date(2045, 12, 01): {
    'foo': 10,
    'bar': 20,
    'qaz': {'qaz_foo': 30,
            'quz_bar': 40
           }
  },
  datetime.date(2067, 12, 01): {
    'foo': 50,
    'bar': 60,
    'qaz': {'qaz_foo': 70,
            'quz_bar': 80
           }
  }
}

0 Answers
Related