Skip to content

Commit ffbe022

Browse files
committed
Fixup
Can't have `__wrapped__` be a property, since some tools check for the presence of `__wrapped__` on all objects, and a property would define that attribute on the class.
1 parent 54641d4 commit ffbe022

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/prefect/tasks/core/function.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def __get__(self, obj, cls):
2626

2727
class FunctionTask(prefect.Task):
2828
__doc__ = _DocProxy(
29-
"""
30-
A convenience Task for functionally creating Task instances with
29+
"""A convenience Task for functionally creating Task instances with
3130
arbitrary callable `run` methods.
3231
3332
Args:
@@ -63,7 +62,7 @@ def __init__(self, fn: Callable, name: str = None, **kwargs: Any):
6362

6463
super().__init__(name=name, **kwargs)
6564

66-
@property
67-
def __wrapped__(self):
68-
"""Propogates information about the wrapped function"""
69-
return self.run
65+
def __getattr__(self, k):
66+
if k == "__wrapped__":
67+
return self.run
68+
raise AttributeError(f"'FunctionTask' object has no attribute {k}")

tests/tasks/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def my_fn():
6969

7070
t = FunctionTask(fn=my_fn)
7171
assert t.__wrapped__ == my_fn
72+
assert not hasattr(FunctionTask, "__wrapped__")
7273

7374

7475
class TestCollections:

0 commit comments

Comments
 (0)