_.isDict
'is this value a Python dict?' — the type-check you'll actually reach for
- obj
- *
_.isDict answers the question you'll actually hit in real ComfyUI work: is this value a dictionary? ComfyUI is full of nodes that output *-typed anything - settings readouts, JSON loaders, environment-variable bridges, combo values - and sometimes what comes out is a dict and sometimes it's a string that looks like one. _.isDict is the guard that tells you which case you're in.
How it works
An exact type test:
def isDict(self):
return self._wrap(type(self.obj) is dict)
type(...) is dict - the strict check, not isinstance. So an actual {} passes, while a JSON string "{}", a list of pairs, or a dict-like custom object all fail. If you want "is it exactly a dict," this is precise. If you want "does it behave like a dict," that's what _.isDictlike is for.
The inputs that matter
One input, one output:
- obj - the primary input (
*), the value being inspected. Also accepts a_.CHAINto continue chaining.
Output is a single * - a real bool at runtime, untyped on the socket because the auto-generator only types standard Underscore.js method names.
Where you'd actually use it
This one has real legs. The defensive pattern: a node like the pack's GetSetting or an environment-variable reader can hand you either a structured dict or a raw string depending on how it was stored. Before you feed that value into something that expects a DICT (a formatter indexing {arg0[key]}, a dict consumer, _.invert or _.keys), a _.isDict check lets you branch: parse it if it's a string, pass it through if it's already a dict. It's the difference between a workflow that silently breaks and one that self-heals.
It also composes with the family: _.isDict (exact), _.isDictlike (duck-typed), _.isCallable (functions), and the numeric checks together make a decent mini data-validator.
Installing
Ships in comfy-ovum (MIT). ComfyUI Manager → search comfy-ovum → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
No extra dependencies for the underscore nodes - the bundled underscore3 port covers them. (Pack-wide requirements.txt includes pymediainfo, which wants system libmediainfo on Linux, but that's unrelated.)
Gotchas
The one trap is the strictness. Because it's type(...) is dict, ordered-dict variants and dict subclasses can fail the check, and a JSON string definitely fails it. When you want "duck-typed dict behavior" instead of "literally a dict," reach for _.isDictlike. And remember the output is untyped *, so the pack README's WIP caveat applies - fine for guards and debug graphs, not a load-bearing production dependency.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |