We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cannot raise a skip signal with a result
I am filing an issue by suggestion of @cicdw after a conversation on gitter.
I came up with the following use case: a task that raises a skip signal with a result because its logic has detected that there is no work to do and the result is already calculated somewhere. I could just return it, but it would be useful for me to know that the _heavy_ part of the task did not actually execute.

An example of the use case would be:

```python
from prefect import task, Flow
from prefect.engine import signals

@task
def test_skipped():
    raise signals.SKIP('skipping', result=5)

f = Flow("test", tasks=[test_skipped])
flow_state = f.run()
```

which fails because of how the `PrefectStateSignal` constructor handles its initialization:

```
Traceback (most recent call last):
  File ".../prefect/engine/signals.py", line 27, in __init__
    result=self, message=message, *args, **kwargs
TypeError: type object got multiple values for keyword argument 'result'
```

Chris suggested the following workaround, which works correctly, but still pointed out that the case above should work.

```python
from prefect import task, Flow
from prefect.engine.runner import ENDRUN
from prefect.engine.state import Skipped

@task
def test_skipped():
    skip = Skipped("skipping", result=5)
    raise ENDRUN(state=skip)

f = Flow("test", tasks=[test_skipped])
flow_state = f.run()

flow_state.result[test_skipped].result # 5
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/prefect/engine/signals.py`
Content:
```
1 """
2 These Exceptions, when raised, are used to signal state changes when tasks or flows are running. Signals
3 are used in TaskRunners and FlowRunners as a way of communicating the changes in states.
4 """
5 
6 from prefect.engine import state
7 from prefect.utilities.exceptions import PrefectError
8 
9 
10 class PrefectStateSignal(PrefectError):
11     """
12     Create a new PrefectStateSignal object.
13 
14     Args:
15         - message (Any, optional): Defaults to `None`. A message about the signal.
16         - *args (Any, optional): additional arguments to pass to this Signal's
17             associated state constructor
18         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
19             associated state constructor
20     """
21 
22     _state_cls = state.State
23 
24     def __init__(self, message: str = None, *args, **kwargs):  # type: ignore
25         super().__init__(message)  # type: ignore
26         self.state = self._state_cls(  # type: ignore
27             result=self, message=message, *args, **kwargs
28         )
29 
30 
31 class FAIL(PrefectStateSignal):
32     """
33     Indicates that a task failed.
34 
35     Args:
36         - message (Any, optional): Defaults to `None`. A message about the signal.
37         - *args (Any, optional): additional arguments to pass to this Signal's
38             associated state constructor
39         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
40             associated state constructor
41     """
42 
43     _state_cls = state.Failed
44 
45 
46 class TRIGGERFAIL(FAIL):
47     """
48     Indicates that a task trigger failed.
49 
50     Args:
51         - message (Any, optional): Defaults to `None`. A message about the signal.
52         - *args (Any, optional): additional arguments to pass to this Signal's
53             associated state constructor
54         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
55             associated state constructor
56     """
57 
58     _state_cls = state.TriggerFailed
59 
60 
61 class SUCCESS(PrefectStateSignal):
62     """
63     Indicates that a task succeeded.
64 
65     Args:
66         - message (Any, optional): Defaults to `None`. A message about the signal.
67         - *args (Any, optional): additional arguments to pass to this Signal's
68             associated state constructor
69         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
70             associated state constructor
71     """
72 
73     _state_cls = state.Success
74 
75 
76 class RETRY(PrefectStateSignal):
77     """
78     Used to indicate that a task should be retried.
79 
80     Args:
81         - message (Any, optional): Defaults to `None`. A message about the signal.
82         - *args (Any, optional): additional arguments to pass to this Signal's
83             associated state constructor
84         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
85             associated state constructor
86     """
87 
88     _state_cls = state.Retrying
89 
90 
91 class SKIP(PrefectStateSignal):
92     """
93     Indicates that a task was skipped. By default, downstream tasks will
94     act as if skipped tasks succeeded.
95 
96     Args:
97         - message (Any, optional): Defaults to `None`. A message about the signal.
98         - *args (Any, optional): additional arguments to pass to this Signal's
99             associated state constructor
100         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
101             associated state constructor
102     """
103 
104     _state_cls = state.Skipped
105 
106 
107 class PAUSE(PrefectStateSignal):
108     """
109     Indicates that a task should not run and wait for manual execution.
110 
111     Args:
112         - message (Any, optional): Defaults to `None`. A message about the signal.
113         - *args (Any, optional): additional arguments to pass to this Signal's
114             associated state constructor
115         - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's
116             associated state constructor
117     """
118 
119     _state_cls = state.Paused
120
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/prefect/engine/signals.py b/src/prefect/engine/signals.py
--- a/src/prefect/engine/signals.py
+++ b/src/prefect/engine/signals.py
@@ -23,8 +23,9 @@
 
     def __init__(self, message: str = None, *args, **kwargs):  # type: ignore
         super().__init__(message)  # type: ignore
+        kwargs.setdefault("result", self)
         self.state = self._state_cls(  # type: ignore
-            result=self, message=message, *args, **kwargs
+            message=message, *args, **kwargs
         )

{"golden_diff": "diff --git a/src/prefect/engine/signals.py b/src/prefect/engine/signals.py\n--- a/src/prefect/engine/signals.py\n+++ b/src/prefect/engine/signals.py\n@@ -23,8 +23,9 @@\n \n     def __init__(self, message: str = None, *args, **kwargs):  # type: ignore\n         super().__init__(message)  # type: ignore\n+        kwargs.setdefault(\"result\", self)\n         self.state = self._state_cls(  # type: ignore\n-            result=self, message=message, *args, **kwargs\n+            message=message, *args, **kwargs\n         )\n", "issue": "Cannot raise a skip signal with a result\nI am filing an issue by suggestion of @cicdw after a conversation on gitter.\r\nI came up with the following use case: a task that raises a skip signal with a result because its logic has detected that there is no work to do and the result is already calculated somewhere. I could just return it, but it would be useful for me to know that the _heavy_ part of the task did not actually execute.\r\n\r\nAn example of the use case would be:\r\n\r\n```python\r\nfrom prefect import task, Flow\r\nfrom prefect.engine import signals\r\n\r\n@task\r\ndef test_skipped():\r\n    raise signals.SKIP('skipping', result=5)\r\n\r\nf = Flow(\"test\", tasks=[test_skipped])\r\nflow_state = f.run()\r\n```\r\n\r\nwhich fails because of how the `PrefectStateSignal` constructor handles its initialization:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \".../prefect/engine/signals.py\", line 27, in __init__\r\n    result=self, message=message, *args, **kwargs\r\nTypeError: type object got multiple values for keyword argument 'result'\r\n```\r\n\r\nChris suggested the following workaround, which works correctly, but still pointed out that the case above should work.\r\n\r\n```python\r\nfrom prefect import task, Flow\r\nfrom prefect.engine.runner import ENDRUN\r\nfrom prefect.engine.state import Skipped\r\n\r\n@task\r\ndef test_skipped():\r\n    skip = Skipped(\"skipping\", result=5)\r\n    raise ENDRUN(state=skip)\r\n\r\nf = Flow(\"test\", tasks=[test_skipped])\r\nflow_state = f.run()\r\n\r\nflow_state.result[test_skipped].result # 5\r\n```\n", "before_files": [{"content": "\"\"\"\nThese Exceptions, when raised, are used to signal state changes when tasks or flows are running. Signals\nare used in TaskRunners and FlowRunners as a way of communicating the changes in states.\n\"\"\"\n\nfrom prefect.engine import state\nfrom prefect.utilities.exceptions import PrefectError\n\n\nclass PrefectStateSignal(PrefectError):\n    \"\"\"\n    Create a new PrefectStateSignal object.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.State\n\n    def __init__(self, message: str = None, *args, **kwargs):  # type: ignore\n        super().__init__(message)  # type: ignore\n        self.state = self._state_cls(  # type: ignore\n            result=self, message=message, *args, **kwargs\n        )\n\n\nclass FAIL(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task failed.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Failed\n\n\nclass TRIGGERFAIL(FAIL):\n    \"\"\"\n    Indicates that a task trigger failed.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.TriggerFailed\n\n\nclass SUCCESS(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task succeeded.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Success\n\n\nclass RETRY(PrefectStateSignal):\n    \"\"\"\n    Used to indicate that a task should be retried.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Retrying\n\n\nclass SKIP(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task was skipped. By default, downstream tasks will\n    act as if skipped tasks succeeded.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Skipped\n\n\nclass PAUSE(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task should not run and wait for manual execution.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Paused\n", "path": "src/prefect/engine/signals.py"}], "after_files": [{"content": "\"\"\"\nThese Exceptions, when raised, are used to signal state changes when tasks or flows are running. Signals\nare used in TaskRunners and FlowRunners as a way of communicating the changes in states.\n\"\"\"\n\nfrom prefect.engine import state\nfrom prefect.utilities.exceptions import PrefectError\n\n\nclass PrefectStateSignal(PrefectError):\n    \"\"\"\n    Create a new PrefectStateSignal object.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.State\n\n    def __init__(self, message: str = None, *args, **kwargs):  # type: ignore\n        super().__init__(message)  # type: ignore\n        kwargs.setdefault(\"result\", self)\n        self.state = self._state_cls(  # type: ignore\n            message=message, *args, **kwargs\n        )\n\n\nclass FAIL(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task failed.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Failed\n\n\nclass TRIGGERFAIL(FAIL):\n    \"\"\"\n    Indicates that a task trigger failed.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.TriggerFailed\n\n\nclass SUCCESS(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task succeeded.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Success\n\n\nclass RETRY(PrefectStateSignal):\n    \"\"\"\n    Used to indicate that a task should be retried.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Retrying\n\n\nclass SKIP(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task was skipped. By default, downstream tasks will\n    act as if skipped tasks succeeded.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Skipped\n\n\nclass PAUSE(PrefectStateSignal):\n    \"\"\"\n    Indicates that a task should not run and wait for manual execution.\n\n    Args:\n        - message (Any, optional): Defaults to `None`. A message about the signal.\n        - *args (Any, optional): additional arguments to pass to this Signal's\n            associated state constructor\n        - **kwargs (Any, optional): additional keyword arguments to pass to this Signal's\n            associated state constructor\n    \"\"\"\n\n    _state_cls = state.Paused\n", "path": "src/prefect/engine/signals.py"}]}