diff --git a/asyncpraw/models/reddit/mixins/editable.py b/asyncpraw/models/reddit/mixins/editable.py index 2c7bc3bc..bc697f09 100644 --- a/asyncpraw/models/reddit/mixins/editable.py +++ b/asyncpraw/models/reddit/mixins/editable.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING, Union from ....const import API_PATH +from ...util import _deprecate_args if TYPE_CHECKING: # pragma: no cover import asyncpraw @@ -26,8 +27,9 @@ async def delete(self): """ await self._reddit.post(API_PATH["del"], data={"id": self.fullname}) + @_deprecate_args("body") async def edit( - self, body + self, *, body: str ) -> Union["asyncpraw.models.Comment", "asyncpraw.models.Submission"]: """Replace the body of the object with ``body``. @@ -44,7 +46,7 @@ async def edit( # construct the text of an edited comment # by appending to the old body: edited_body = comment.body + "Edit: thanks for the gold!" - await comment.edit(edited_body) + await comment.edit(body=edited_body) """ data = { diff --git a/tests/integration/models/reddit/test_comment.py b/tests/integration/models/reddit/test_comment.py index 6e784c15..d064c5d1 100644 --- a/tests/integration/models/reddit/test_comment.py +++ b/tests/integration/models/reddit/test_comment.py @@ -61,7 +61,7 @@ async def test_edit(self, _): self.reddit.read_only = False with self.use_cassette(): comment = Comment(self.reddit, "fwxxs5d") - await comment.edit("New text") + await comment.edit(body="New text") assert comment.body == "New text" async def test_enable_inbox_replies(self): diff --git a/tests/integration/models/reddit/test_submission.py b/tests/integration/models/reddit/test_submission.py index 11e1425d..1ec922a6 100644 --- a/tests/integration/models/reddit/test_submission.py +++ b/tests/integration/models/reddit/test_submission.py @@ -60,7 +60,7 @@ async def test_edit(self, _): self.reddit.read_only = False with self.use_cassette(): submission = Submission(self.reddit, "hmkbt8") - await submission.edit("New text") + await submission.edit(body="New text") assert submission.selftext == "New text" @mock.patch("asyncio.sleep", return_value=None) @@ -70,7 +70,7 @@ async def test_edit_invalid(self, _): with self.use_cassette(): submission = Submission(self.reddit, "hmkfoy") with pytest.raises(RedditAPIException): - await submission.edit("rewtwert") + await submission.edit(body="rewtwert") async def test_enable_inbox_replies(self): self.reddit.read_only = False