For example I have a poorly documented library. I have an object from it and I want to know what are the types of the arguments certain method accepts.
In IPython I can run
In : tdb.getData?
Signature: tdb.getData(time, point_coords, sinterp=0, tinterp=0, data_set='isotropic1024coarse', getFunction='getVelocity', make_modulo=False)
Docstring: <no docstring>
Usually, functions in Python accept arguments of any type, so you cannot define what type it expects.
Still, the function probably does make some implicit assumptions about the received object.
Take this function for example:
def is_long(x): return len(x) > 1000
What type of argument
x does this function accept? Any type, as long as it has length defined.
So, it can take a string, or a list, or a dict, or any custom object you create, as long as it implements
__len__. But it won't take an integer.
is_long('abcd') # ok is_long([1, 2, 3, 4]) # ok is_long(11) # not ok
To answer the question: How can you tell what assumtions the function makes?