diff --git a/src/prefect/tasks/core/function.py b/src/prefect/tasks/core/function.py index 5ac58916aca7..0021a0ed7496 100644 --- a/src/prefect/tasks/core/function.py +++ b/src/prefect/tasks/core/function.py @@ -26,8 +26,7 @@ def __get__(self, obj, cls): class FunctionTask(prefect.Task): __doc__ = _DocProxy( - """ - A convenience Task for functionally creating Task instances with + """A convenience Task for functionally creating Task instances with arbitrary callable `run` methods. Args: @@ -63,7 +62,7 @@ def __init__(self, fn: Callable, name: str = None, **kwargs: Any): super().__init__(name=name, **kwargs) - @property - def __wrapped__(self): - """Propogates information about the wrapped function""" - return self.run + def __getattr__(self, k): + if k == "__wrapped__": + return self.run + raise AttributeError(f"'FunctionTask' object has no attribute {k}") diff --git a/tests/tasks/test_core.py b/tests/tasks/test_core.py index 0a60a8c278e5..1c57a86a4680 100644 --- a/tests/tasks/test_core.py +++ b/tests/tasks/test_core.py @@ -69,6 +69,7 @@ def my_fn(): t = FunctionTask(fn=my_fn) assert t.__wrapped__ == my_fn + assert not hasattr(FunctionTask, "__wrapped__") class TestCollections: