We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
swarm.init() does not return a value
No return value unlike as specified in documentation. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/models/swarm.py`
Content:
```
1 from docker.api import APIClient
2 from docker.errors import APIError
3 from .resource import Model
4 
5 
6 class Swarm(Model):
7     """
8     The server's Swarm state. This a singleton that must be reloaded to get
9     the current state of the Swarm.
10     """
11     id_attribute = 'ID'
12 
13     def __init__(self, *args, **kwargs):
14         super(Swarm, self).__init__(*args, **kwargs)
15         if self.client:
16             try:
17                 self.reload()
18             except APIError as e:
19                 # FIXME: https://github.com/docker/docker/issues/29192
20                 if e.response.status_code not in (406, 503):
21                     raise
22 
23     @property
24     def version(self):
25         """
26         The version number of the swarm. If this is not the same as the
27         server, the :py:meth:`update` function will not work and you will
28         need to call :py:meth:`reload` before calling it again.
29         """
30         return self.attrs.get('Version').get('Index')
31 
32     def get_unlock_key(self):
33         return self.client.api.get_unlock_key()
34     get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__
35 
36     def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377',
37              force_new_cluster=False, **kwargs):
38         """
39         Initialize a new swarm on this Engine.
40 
41         Args:
42             advertise_addr (str): Externally reachable address advertised to
43                 other nodes. This can either be an address/port combination in
44                 the form ``192.168.1.1:4567``, or an interface followed by a
45                 port number, like ``eth0:4567``. If the port number is omitted,
46                 the port number from the listen address is used.
47 
48                 If not specified, it will be automatically detected when
49                 possible.
50             listen_addr (str): Listen address used for inter-manager
51                 communication, as well as determining the networking interface
52                 used for the VXLAN Tunnel Endpoint (VTEP). This can either be
53                 an address/port combination in the form ``192.168.1.1:4567``,
54                 or an interface followed by a port number, like ``eth0:4567``.
55                 If the port number is omitted, the default swarm listening port
56                 is used. Default: ``0.0.0.0:2377``
57             force_new_cluster (bool): Force creating a new Swarm, even if
58                 already part of one. Default: False
59             task_history_retention_limit (int): Maximum number of tasks
60                 history stored.
61             snapshot_interval (int): Number of logs entries between snapshot.
62             keep_old_snapshots (int): Number of snapshots to keep beyond the
63                 current snapshot.
64             log_entries_for_slow_followers (int): Number of log entries to
65                 keep around to sync up slow followers after a snapshot is
66                 created.
67             heartbeat_tick (int): Amount of ticks (in seconds) between each
68                 heartbeat.
69             election_tick (int): Amount of ticks (in seconds) needed without a
70                 leader to trigger a new election.
71             dispatcher_heartbeat_period (int):  The delay for an agent to send
72                 a heartbeat to the dispatcher.
73             node_cert_expiry (int): Automatic expiry for nodes certificates.
74             external_ca (dict): Configuration for forwarding signing requests
75                 to an external certificate authority. Use
76                 ``docker.types.SwarmExternalCA``.
77             name (string): Swarm's name
78             labels (dict): User-defined key/value metadata.
79             signing_ca_cert (str): The desired signing CA certificate for all
80                 swarm node TLS leaf certificates, in PEM format.
81             signing_ca_key (str): The desired signing CA key for all swarm
82                 node TLS leaf certificates, in PEM format.
83             ca_force_rotate (int): An integer whose purpose is to force swarm
84                 to generate a new signing CA certificate and key, if none have
85                 been specified.
86             autolock_managers (boolean): If set, generate a key and use it to
87                 lock data stored on the managers.
88             log_driver (DriverConfig): The default log driver to use for tasks
89                 created in the orchestrator.
90 
91         Returns:
92             ``True`` if the request went through.
93 
94         Raises:
95             :py:class:`docker.errors.APIError`
96                 If the server returns an error.
97 
98         Example:
99 
100             >>> client.swarm.init(
101                 advertise_addr='eth0', listen_addr='0.0.0.0:5000',
102                 force_new_cluster=False, snapshot_interval=5000,
103                 log_entries_for_slow_followers=1200
104             )
105 
106         """
107         init_kwargs = {
108             'advertise_addr': advertise_addr,
109             'listen_addr': listen_addr,
110             'force_new_cluster': force_new_cluster
111         }
112         init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
113         self.client.api.init_swarm(**init_kwargs)
114         self.reload()
115 
116     def join(self, *args, **kwargs):
117         return self.client.api.join_swarm(*args, **kwargs)
118     join.__doc__ = APIClient.join_swarm.__doc__
119 
120     def leave(self, *args, **kwargs):
121         return self.client.api.leave_swarm(*args, **kwargs)
122     leave.__doc__ = APIClient.leave_swarm.__doc__
123 
124     def reload(self):
125         """
126         Inspect the swarm on the server and store the response in
127         :py:attr:`attrs`.
128 
129         Raises:
130             :py:class:`docker.errors.APIError`
131                 If the server returns an error.
132         """
133         self.attrs = self.client.api.inspect_swarm()
134 
135     def unlock(self, key):
136         return self.client.api.unlock_swarm(key)
137     unlock.__doc__ = APIClient.unlock_swarm.__doc__
138 
139     def update(self, rotate_worker_token=False, rotate_manager_token=False,
140                **kwargs):
141         """
142         Update the swarm's configuration.
143 
144         It takes the same arguments as :py:meth:`init`, except
145         ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``. In
146         addition, it takes these arguments:
147 
148         Args:
149             rotate_worker_token (bool): Rotate the worker join token. Default:
150                 ``False``.
151             rotate_manager_token (bool): Rotate the manager join token.
152                 Default: ``False``.
153 
154         Raises:
155             :py:class:`docker.errors.APIError`
156                 If the server returns an error.
157 
158         """
159         # this seems to have to be set
160         if kwargs.get('node_cert_expiry') is None:
161             kwargs['node_cert_expiry'] = 7776000000000000
162 
163         return self.client.api.update_swarm(
164             version=self.version,
165             swarm_spec=self.client.api.create_swarm_spec(**kwargs),
166             rotate_worker_token=rotate_worker_token,
167             rotate_manager_token=rotate_manager_token
168         )
169
```
--- 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/docker/models/swarm.py b/docker/models/swarm.py
--- a/docker/models/swarm.py
+++ b/docker/models/swarm.py
@@ -112,6 +112,7 @@
         init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
         self.client.api.init_swarm(**init_kwargs)
         self.reload()
+        return True
 
     def join(self, *args, **kwargs):
         return self.client.api.join_swarm(*args, **kwargs)

{"golden_diff": "diff --git a/docker/models/swarm.py b/docker/models/swarm.py\n--- a/docker/models/swarm.py\n+++ b/docker/models/swarm.py\n@@ -112,6 +112,7 @@\n         init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)\n         self.client.api.init_swarm(**init_kwargs)\n         self.reload()\n+        return True\n \n     def join(self, *args, **kwargs):\n         return self.client.api.join_swarm(*args, **kwargs)\n", "issue": "swarm.init() does not return a value\nNo return value unlike as specified in documentation. \n", "before_files": [{"content": "from docker.api import APIClient\nfrom docker.errors import APIError\nfrom .resource import Model\n\n\nclass Swarm(Model):\n    \"\"\"\n    The server's Swarm state. This a singleton that must be reloaded to get\n    the current state of the Swarm.\n    \"\"\"\n    id_attribute = 'ID'\n\n    def __init__(self, *args, **kwargs):\n        super(Swarm, self).__init__(*args, **kwargs)\n        if self.client:\n            try:\n                self.reload()\n            except APIError as e:\n                # FIXME: https://github.com/docker/docker/issues/29192\n                if e.response.status_code not in (406, 503):\n                    raise\n\n    @property\n    def version(self):\n        \"\"\"\n        The version number of the swarm. If this is not the same as the\n        server, the :py:meth:`update` function will not work and you will\n        need to call :py:meth:`reload` before calling it again.\n        \"\"\"\n        return self.attrs.get('Version').get('Index')\n\n    def get_unlock_key(self):\n        return self.client.api.get_unlock_key()\n    get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__\n\n    def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377',\n             force_new_cluster=False, **kwargs):\n        \"\"\"\n        Initialize a new swarm on this Engine.\n\n        Args:\n            advertise_addr (str): Externally reachable address advertised to\n                other nodes. This can either be an address/port combination in\n                the form ``192.168.1.1:4567``, or an interface followed by a\n                port number, like ``eth0:4567``. If the port number is omitted,\n                the port number from the listen address is used.\n\n                If not specified, it will be automatically detected when\n                possible.\n            listen_addr (str): Listen address used for inter-manager\n                communication, as well as determining the networking interface\n                used for the VXLAN Tunnel Endpoint (VTEP). This can either be\n                an address/port combination in the form ``192.168.1.1:4567``,\n                or an interface followed by a port number, like ``eth0:4567``.\n                If the port number is omitted, the default swarm listening port\n                is used. Default: ``0.0.0.0:2377``\n            force_new_cluster (bool): Force creating a new Swarm, even if\n                already part of one. Default: False\n            task_history_retention_limit (int): Maximum number of tasks\n                history stored.\n            snapshot_interval (int): Number of logs entries between snapshot.\n            keep_old_snapshots (int): Number of snapshots to keep beyond the\n                current snapshot.\n            log_entries_for_slow_followers (int): Number of log entries to\n                keep around to sync up slow followers after a snapshot is\n                created.\n            heartbeat_tick (int): Amount of ticks (in seconds) between each\n                heartbeat.\n            election_tick (int): Amount of ticks (in seconds) needed without a\n                leader to trigger a new election.\n            dispatcher_heartbeat_period (int):  The delay for an agent to send\n                a heartbeat to the dispatcher.\n            node_cert_expiry (int): Automatic expiry for nodes certificates.\n            external_ca (dict): Configuration for forwarding signing requests\n                to an external certificate authority. Use\n                ``docker.types.SwarmExternalCA``.\n            name (string): Swarm's name\n            labels (dict): User-defined key/value metadata.\n            signing_ca_cert (str): The desired signing CA certificate for all\n                swarm node TLS leaf certificates, in PEM format.\n            signing_ca_key (str): The desired signing CA key for all swarm\n                node TLS leaf certificates, in PEM format.\n            ca_force_rotate (int): An integer whose purpose is to force swarm\n                to generate a new signing CA certificate and key, if none have\n                been specified.\n            autolock_managers (boolean): If set, generate a key and use it to\n                lock data stored on the managers.\n            log_driver (DriverConfig): The default log driver to use for tasks\n                created in the orchestrator.\n\n        Returns:\n            ``True`` if the request went through.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> client.swarm.init(\n                advertise_addr='eth0', listen_addr='0.0.0.0:5000',\n                force_new_cluster=False, snapshot_interval=5000,\n                log_entries_for_slow_followers=1200\n            )\n\n        \"\"\"\n        init_kwargs = {\n            'advertise_addr': advertise_addr,\n            'listen_addr': listen_addr,\n            'force_new_cluster': force_new_cluster\n        }\n        init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)\n        self.client.api.init_swarm(**init_kwargs)\n        self.reload()\n\n    def join(self, *args, **kwargs):\n        return self.client.api.join_swarm(*args, **kwargs)\n    join.__doc__ = APIClient.join_swarm.__doc__\n\n    def leave(self, *args, **kwargs):\n        return self.client.api.leave_swarm(*args, **kwargs)\n    leave.__doc__ = APIClient.leave_swarm.__doc__\n\n    def reload(self):\n        \"\"\"\n        Inspect the swarm on the server and store the response in\n        :py:attr:`attrs`.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        self.attrs = self.client.api.inspect_swarm()\n\n    def unlock(self, key):\n        return self.client.api.unlock_swarm(key)\n    unlock.__doc__ = APIClient.unlock_swarm.__doc__\n\n    def update(self, rotate_worker_token=False, rotate_manager_token=False,\n               **kwargs):\n        \"\"\"\n        Update the swarm's configuration.\n\n        It takes the same arguments as :py:meth:`init`, except\n        ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``. In\n        addition, it takes these arguments:\n\n        Args:\n            rotate_worker_token (bool): Rotate the worker join token. Default:\n                ``False``.\n            rotate_manager_token (bool): Rotate the manager join token.\n                Default: ``False``.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        \"\"\"\n        # this seems to have to be set\n        if kwargs.get('node_cert_expiry') is None:\n            kwargs['node_cert_expiry'] = 7776000000000000\n\n        return self.client.api.update_swarm(\n            version=self.version,\n            swarm_spec=self.client.api.create_swarm_spec(**kwargs),\n            rotate_worker_token=rotate_worker_token,\n            rotate_manager_token=rotate_manager_token\n        )\n", "path": "docker/models/swarm.py"}], "after_files": [{"content": "from docker.api import APIClient\nfrom docker.errors import APIError\nfrom .resource import Model\n\n\nclass Swarm(Model):\n    \"\"\"\n    The server's Swarm state. This a singleton that must be reloaded to get\n    the current state of the Swarm.\n    \"\"\"\n    id_attribute = 'ID'\n\n    def __init__(self, *args, **kwargs):\n        super(Swarm, self).__init__(*args, **kwargs)\n        if self.client:\n            try:\n                self.reload()\n            except APIError as e:\n                # FIXME: https://github.com/docker/docker/issues/29192\n                if e.response.status_code not in (406, 503):\n                    raise\n\n    @property\n    def version(self):\n        \"\"\"\n        The version number of the swarm. If this is not the same as the\n        server, the :py:meth:`update` function will not work and you will\n        need to call :py:meth:`reload` before calling it again.\n        \"\"\"\n        return self.attrs.get('Version').get('Index')\n\n    def get_unlock_key(self):\n        return self.client.api.get_unlock_key()\n    get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__\n\n    def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377',\n             force_new_cluster=False, **kwargs):\n        \"\"\"\n        Initialize a new swarm on this Engine.\n\n        Args:\n            advertise_addr (str): Externally reachable address advertised to\n                other nodes. This can either be an address/port combination in\n                the form ``192.168.1.1:4567``, or an interface followed by a\n                port number, like ``eth0:4567``. If the port number is omitted,\n                the port number from the listen address is used.\n\n                If not specified, it will be automatically detected when\n                possible.\n            listen_addr (str): Listen address used for inter-manager\n                communication, as well as determining the networking interface\n                used for the VXLAN Tunnel Endpoint (VTEP). This can either be\n                an address/port combination in the form ``192.168.1.1:4567``,\n                or an interface followed by a port number, like ``eth0:4567``.\n                If the port number is omitted, the default swarm listening port\n                is used. Default: ``0.0.0.0:2377``\n            force_new_cluster (bool): Force creating a new Swarm, even if\n                already part of one. Default: False\n            task_history_retention_limit (int): Maximum number of tasks\n                history stored.\n            snapshot_interval (int): Number of logs entries between snapshot.\n            keep_old_snapshots (int): Number of snapshots to keep beyond the\n                current snapshot.\n            log_entries_for_slow_followers (int): Number of log entries to\n                keep around to sync up slow followers after a snapshot is\n                created.\n            heartbeat_tick (int): Amount of ticks (in seconds) between each\n                heartbeat.\n            election_tick (int): Amount of ticks (in seconds) needed without a\n                leader to trigger a new election.\n            dispatcher_heartbeat_period (int):  The delay for an agent to send\n                a heartbeat to the dispatcher.\n            node_cert_expiry (int): Automatic expiry for nodes certificates.\n            external_ca (dict): Configuration for forwarding signing requests\n                to an external certificate authority. Use\n                ``docker.types.SwarmExternalCA``.\n            name (string): Swarm's name\n            labels (dict): User-defined key/value metadata.\n            signing_ca_cert (str): The desired signing CA certificate for all\n                swarm node TLS leaf certificates, in PEM format.\n            signing_ca_key (str): The desired signing CA key for all swarm\n                node TLS leaf certificates, in PEM format.\n            ca_force_rotate (int): An integer whose purpose is to force swarm\n                to generate a new signing CA certificate and key, if none have\n                been specified.\n            autolock_managers (boolean): If set, generate a key and use it to\n                lock data stored on the managers.\n            log_driver (DriverConfig): The default log driver to use for tasks\n                created in the orchestrator.\n\n        Returns:\n            ``True`` if the request went through.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> client.swarm.init(\n                advertise_addr='eth0', listen_addr='0.0.0.0:5000',\n                force_new_cluster=False, snapshot_interval=5000,\n                log_entries_for_slow_followers=1200\n            )\n\n        \"\"\"\n        init_kwargs = {\n            'advertise_addr': advertise_addr,\n            'listen_addr': listen_addr,\n            'force_new_cluster': force_new_cluster\n        }\n        init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)\n        self.client.api.init_swarm(**init_kwargs)\n        self.reload()\n        return True\n\n    def join(self, *args, **kwargs):\n        return self.client.api.join_swarm(*args, **kwargs)\n    join.__doc__ = APIClient.join_swarm.__doc__\n\n    def leave(self, *args, **kwargs):\n        return self.client.api.leave_swarm(*args, **kwargs)\n    leave.__doc__ = APIClient.leave_swarm.__doc__\n\n    def reload(self):\n        \"\"\"\n        Inspect the swarm on the server and store the response in\n        :py:attr:`attrs`.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        self.attrs = self.client.api.inspect_swarm()\n\n    def unlock(self, key):\n        return self.client.api.unlock_swarm(key)\n    unlock.__doc__ = APIClient.unlock_swarm.__doc__\n\n    def update(self, rotate_worker_token=False, rotate_manager_token=False,\n               **kwargs):\n        \"\"\"\n        Update the swarm's configuration.\n\n        It takes the same arguments as :py:meth:`init`, except\n        ``advertise_addr``, ``listen_addr``, and ``force_new_cluster``. In\n        addition, it takes these arguments:\n\n        Args:\n            rotate_worker_token (bool): Rotate the worker join token. Default:\n                ``False``.\n            rotate_manager_token (bool): Rotate the manager join token.\n                Default: ``False``.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        \"\"\"\n        # this seems to have to be set\n        if kwargs.get('node_cert_expiry') is None:\n            kwargs['node_cert_expiry'] = 7776000000000000\n\n        return self.client.api.update_swarm(\n            version=self.version,\n            swarm_spec=self.client.api.create_swarm_spec(**kwargs),\n            rotate_worker_token=rotate_worker_token,\n            rotate_manager_token=rotate_manager_token\n        )\n", "path": "docker/models/swarm.py"}]}