MCPcopy
hub / github.com/dask/dask / funcname

Function funcname

dask/utils.py:1018–1047  ·  view source on GitHub ↗

Get the name of a function.

(func)

Source from the content-addressed store, hash-verified

1016
1017
1018def funcname(func) -> str:
1019 """Get the name of a function."""
1020 # functools.partial
1021 if isinstance(func, functools.partial):
1022 return funcname(func.func)
1023 # methodcaller
1024 if isinstance(func, methodcaller):
1025 return func.method[:50]
1026
1027 module_name = getattr(func, "__module__", None) or ""
1028 type_name = getattr(type(func), "__name__", None) or ""
1029
1030 # toolz.curry
1031 if "toolz" in module_name and "curry" == type_name:
1032 return func.func_name[:50]
1033 # multipledispatch objects
1034 if "multipledispatch" in module_name and "Dispatcher" == type_name:
1035 return func.name[:50]
1036 # numpy.vectorize objects
1037 if "numpy" in module_name and "vectorize" == type_name:
1038 return ("vectorize_" + funcname(func.pyfunc))[:50]
1039
1040 # All other callables
1041 try:
1042 name = func.__name__
1043 if name == "<lambda>":
1044 return "lambda"
1045 return name[:50]
1046 except AttributeError:
1047 return str(func)[:50]
1048
1049
1050def typename(typ: Any, short: bool = False) -> str:

Callers 15

task_labelFunction · 0.90
_funcnameMethod · 0.90
_to_graphvizMethod · 0.90
call_functionFunction · 0.90
__repr__Method · 0.90
wrapperMethod · 0.90
applyMethod · 0.90
starmapMethod · 0.90
filterMethod · 0.90
removeMethod · 0.90
reductionMethod · 0.90
accumulateMethod · 0.90

Calls

no outgoing calls

Tested by 8

test_nameFunction · 0.72
test_linear_fusionFunction · 0.72
test_funcnameFunction · 0.72
test_funcname_longFunction · 0.72
test_funcname_toolzFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…