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

Function is_namedtuple_instance

dask/utils.py:2210–2224  ·  view source on GitHub ↗

Returns True if obj is an instance of a namedtuple. Note: This function checks for the existence of the methods and attributes that make up the namedtuple API, so it will return True IFF obj's type implements that API.

(obj: Any)

Source from the content-addressed store, hash-verified

2208
2209
2210def is_namedtuple_instance(obj: Any) -> bool:
2211 """Returns True if obj is an instance of a namedtuple.
2212
2213 Note: This function checks for the existence of the methods and
2214 attributes that make up the namedtuple API, so it will return True
2215 IFF obj's type implements that API.
2216 """
2217 return (
2218 isinstance(obj, tuple)
2219 and hasattr(obj, "_make")
2220 and hasattr(obj, "_asdict")
2221 and hasattr(obj, "_replace")
2222 and hasattr(obj, "_fields")
2223 and hasattr(obj, "_field_defaults")
2224 )
2225
2226
2227def get_default_shuffle_method() -> str:

Callers 4

to_task_daskFunction · 0.90
_unpackFunction · 0.90
parse_inputFunction · 0.90
convert_legacy_taskFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected