nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: hikari-py/hikari
Pull request #2287 (2025-04-02 03:21:48)

Fix `end_poll` method in `RESTClient`.
### Summary
Fix `end_poll` method in `RESTClient` to return a message object instead of `None`.

### Checklist
- [x] I have run `nox` and all the pipelines have passed.
- [x] I have made unittests according to the code I have added/modified/deleted.



Patch:
diff --git a/hikari/api/rest.py b/hikari/api/rest.py
index 6c3d5d51..786f9ad2 100644
--- a/hikari/api/rest.py
+++ b/hikari/api/rest.py
@@ -8672,7 +8672,7 @@ async def end_poll(
         channel: snowflakes.SnowflakeishOr[channels_.TextableChannel],
         message: snowflakes.SnowflakeishOr[messages_.PartialMessage],
         /,
-    ) -> None:
+    ) -> messages_.Message:
         """End a poll.
 
         Parameters
@@ -8682,6 +8682,11 @@ async def end_poll(
         message
             The message the poll is in.
 
+        Returns
+        -------
+        hikari.messages.Message
+            The message that had its poll ended.
+
         Raises
         ------
         hikari.errors.BadRequestError
diff --git a/hikari/impl/rest.py b/hikari/impl/rest.py
index ba4b350b..19dcbb2e 100644
--- a/hikari/impl/rest.py
+++ b/hikari/impl/rest.py
@@ -4803,7 +4803,9 @@ async def end_poll(
         channel: snowflakes.SnowflakeishOr[channels_.TextableChannel],
         message: snowflakes.SnowflakeishOr[messages_.PartialMessage],
         /,
-    ) -> None:
+    ) -> messages_.Message:
         route = routes.POST_EXPIRE_POLL.compile(channel=channel, message=message)
 
-        await self._request(route)
+        response = await self._request(route)
+        assert isinstance(response, dict)
+        return self._entity_factory.deserialize_message(response)


Test patch:
diff --git a/tests/hikari/impl/test_rest.py b/tests/hikari/impl/test_rest.py
index 263220f0..2aa52ef2 100644
--- a/tests/hikari/impl/test_rest.py
+++ b/tests/hikari/impl/test_rest.py
@@ -6741,8 +6741,15 @@ async def test_end_poll(self, rest_client: rest.RESTClientImpl):
         expected_route = routes.POST_EXPIRE_POLL.compile(
             channel=StubModel(45874392), message=StubModel(398475938475), answer=StubModel(4)
         )
-        rest_client._request = mock.AsyncMock()
 
-        await rest_client.end_poll(StubModel(45874392), StubModel(398475938475))
+        message_obj = mock.Mock()
+
+        rest_client._request = mock.AsyncMock(return_value={"id": "398475938475"})
+
+        rest_client._entity_factory.deserialize_message = mock.Mock(return_value=message_obj)
+
+        response = await rest_client.end_poll(StubModel(45874392), StubModel(398475938475))
 
         rest_client._request.assert_awaited_once_with(expected_route)
+
+        assert response is message_obj