Reimus Klinsman
Reimus Klinsman

Reputation: 947

How to document that an argument could be any type

I have a function that is adding a set of values to a dictionary. Those values could effectively be any type that is JSON serializable. I am having trouble writing effective documentation for the function. Throughout the program I have all arguments listed with the type, name, and description but what should I write if the type doesn't matter? I think it would be odd to say the type is any or just omit it altogether.

The current documentation I am working with looks like this, if it helps

"""
Adds an entry into payload["updated_values"]

@param dict payload: Payload to be recorded
@param str name: Name of the field we are adding to the payload
@param ### old: # <-- Looking for what to add here  
@param ### new:
@return:
"""

Upvotes: 0

Views: 31

Answers (1)

marcos
marcos

Reputation: 4510

You can use this in python 3:

from typing import Any

def foo(bar: Any):
    pass

Upvotes: 2

Related Questions