MCPcopy
hub / github.com/dask/dask / typename

Function typename

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

Return the name of a type Examples -------- >>> typename(int) 'int' >>> from dask.core import literal >>> typename(literal) 'dask.core.literal' >>> typename(literal, short=True) 'dask.literal'

(typ: Any, short: bool = False)

Source from the content-addressed store, hash-verified

1048
1049
1050def typename(typ: Any, short: bool = False) -> str:
1051 """
1052 Return the name of a type
1053
1054 Examples
1055 --------
1056 >>> typename(int)
1057 'int'
1058
1059 >>> from dask.core import literal
1060 >>> typename(literal)
1061 'dask.core.literal'
1062 >>> typename(literal, short=True)
1063 'dask.literal'
1064 """
1065 if not isinstance(typ, type):
1066 return typename(type(typ))
1067 try:
1068 if not typ.__module__ or typ.__module__ == "builtins":
1069 return typ.__name__
1070 else:
1071 if short:
1072 module, *_ = typ.__module__.split(".")
1073 else:
1074 module = typ.__module__
1075 return f"{module}.{typ.__name__}"
1076 except AttributeError:
1077 return str(typ)
1078
1079
1080def ensure_bytes(s) -> bytes:

Callers 15

_nonempty_scalarFunction · 0.90
check_metaFunction · 0.90
meta_nonempty_objectFunction · 0.90
_nonempty_indexFunction · 0.90
isinMethod · 0.90
handle_outFunction · 0.90
_set_parquet_engineFunction · 0.90
test_typenameFunction · 0.90
__new__Method · 0.90
_repr_html_Method · 0.90
__getattr__Function · 0.90

Calls 1

splitMethod · 0.80

Tested by 2

test_typenameFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…