Skip to content

Commit

Permalink
Sort asyncpraw.models.reddit.mixins.editable.EditableMixin.edit argum…
Browse files Browse the repository at this point in the history
…ents

(cherry picked from commit praw-dev/praw@aaed20d)
  • Loading branch information
LilSpazJoekp committed Oct 17, 2022
1 parent 03ca828 commit bef087a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions asyncpraw/models/reddit/mixins/editable.py
Expand Up @@ -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
Expand All @@ -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``.
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/models/reddit/test_comment.py
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/models/reddit/test_submission.py
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit bef087a

Please sign in to comment.