diff --git a/pyiron_workflow/nodes/transform.py b/pyiron_workflow/nodes/transform.py index 6a4371bed..c3c861a91 100644 --- a/pyiron_workflow/nodes/transform.py +++ b/pyiron_workflow/nodes/transform.py @@ -386,7 +386,7 @@ def _extra_info(cls) -> str: def dataclass_node_factory( dataclass: type, use_cache: bool = True, / ) -> type[DataclassNode]: - if type(dataclass) is not type: + if not isinstance(dataclass, type): raise TypeError( f"{DataclassNode} expected to get a dataclass but {dataclass} is not " f"type `type`." diff --git a/tests/unit/nodes/test_transform.py b/tests/unit/nodes/test_transform.py index e9bef9d6f..156cf87ee 100644 --- a/tests/unit/nodes/test_transform.py +++ b/tests/unit/nodes/test_transform.py @@ -1,6 +1,7 @@ import pickle import random import unittest +from abc import ABC, abstractmethod from dataclasses import dataclass, field, is_dataclass from pandas import DataFrame @@ -249,6 +250,23 @@ class DecoratedDCLike: "instantiation", ) + with self.subTest("From instantiated ABC"): + + class MyAbstractData(ABC): + @abstractmethod + def shout(self): + pass + + try: + @as_dataclass_node + class MyConcreteData(MyAbstractData): + name: str + def shout(self): + return f"!{self.name}!" + except: # noqa: E722 + self.fail("Wrapping an implementation of an ABC should not raise exceptions!") + + def test_dataclass_typing_and_storage(self): md = MyData()