MCPcopy Create free account
hub / github.com/dask/dask / funcname

Function funcname

dask/utils.py:1021–1050  ·  view source on GitHub ↗

Get the name of a function.

(func)

Source from the content-addressed store, hash-verified

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