_.isClass
'is this value a class/type?'
- obj
- *
_.isClass checks whether a value is a Python class (a type). It's the introspection node in this pack's type-check family for the "is this a thing I could instantiate?" question - distinct from _.isCallable (which would also say yes to a class, plus functions and instances) and from _.isBuiltinFunction (which is only about C-built-ins).
How it works
The port uses Python's own introspection instead of a raw type comparison:
def isClass(self):
return self._wrap(inspect.isclass(self.obj))
inspect.isclass returns true for classes and false for instances, functions, lambdas, and modules. So str passes, "hello" fails, and a function object fails even though it's callable. It's the precise "this is a type you could use in a constructor" test.
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 generator only types the standard Underscore.js method names, and isClass isn't one of them.
Where you'd actually use it
The honest use case is narrow, and it's the same story as _.isBuiltinFunction and _.isBuiltinMethod: you need this only when you're doing meta-work where actual classes are flowing around as values - building iteratees from the pack's UnderscoreExports node, inspecting function-typed sockets, or debugging why a "callable" turned out to be a class instead of a function. In that world, _.isClass is how you tell a constructor from a callable. In a normal image pipeline, it will not come up, and that's fine.
Installing
Part of 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 themselves - the bundled underscore3 port covers them.
Gotchas
Untyped * output, WIP status per the pack README, and one conceptual trap: because classes are callable in Python, _.isClass and _.isCallable both return true for the same value - a class. The difference only shows up on functions, instances, and lambdas. If you're guarding a call site, _.isCallable is the broader safety net; if you specifically need to know whether you're holding a type, this is the one.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |