Skip to content

Commit a381420

Browse files
authored
Merge pull request #216 from praw-dev/positional_argument_reverts
Revert `EditableMixin.edit` positional argument deprecation
2 parents 38f2238 + bb8c7a7 commit a381420

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Async PRAW follows `semantic versioning <http://semver.org/>`_.
66
Unreleased
77
----------
88

9+
**Changed**
10+
11+
- Revert :meth:`~.Comment.edit` positional argument deprecation.
12+
- Revert :meth:`~.Submission.edit` positional argument deprecation.
13+
914
**Fixed**
1015

1116
- An issue where :class:`.ModmailConversation`'s ``messages`` attribute would only

asyncpraw/models/reddit/mixins/editable.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import TYPE_CHECKING, Union
33

44
from ....const import API_PATH
5-
from ...util import _deprecate_args
65

76
if TYPE_CHECKING: # pragma: no cover
87
import asyncpraw
@@ -27,9 +26,8 @@ async def delete(self):
2726
"""
2827
await self._reddit.post(API_PATH["del"], data={"id": self.fullname})
2928

30-
@_deprecate_args("body")
3129
async def edit(
32-
self, *, body: str
30+
self, body: str
3331
) -> Union["asyncpraw.models.Comment", "asyncpraw.models.Submission"]:
3432
"""Replace the body of the object with ``body``.
3533
@@ -46,7 +44,7 @@ async def edit(
4644
# construct the text of an edited comment
4745
# by appending to the old body:
4846
edited_body = comment.body + "Edit: thanks for the gold!"
49-
await comment.edit(body=edited_body)
47+
await comment.edit(edited_body)
5048
5149
"""
5250
data = {

asyncpraw/models/reddit/mixins/replyable.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Provide the ReplyableMixin class."""
2-
from typing import TYPE_CHECKING, Optional
2+
from typing import TYPE_CHECKING, Optional, Union
33

44
from ....const import API_PATH
55

@@ -10,13 +10,15 @@
1010
class ReplyableMixin:
1111
"""Interface for :class:`.RedditBase` classes that can be replied to."""
1212

13-
async def reply(self, body: str) -> Optional["asyncpraw.models.Comment"]:
13+
async def reply(
14+
self, body: str
15+
) -> Optional[Union["asyncpraw.models.Comment", "asyncpraw.models.Message"]]:
1416
"""Reply to the object.
1517
1618
:param body: The Markdown formatted content for a comment.
1719
18-
:returns: A :class:`.Comment` object for the newly created comment or ``None``
19-
if Reddit doesn't provide one.
20+
:returns: A :class:`.Comment` or :class:`.Message` object for the newly created
21+
comment or message or ``None`` if Reddit doesn't provide one.
2022
2123
:raises: ``asyncprawcore.exceptions.Forbidden`` when attempting to reply to some
2224
items, such as locked submissions/comments or non-replyable messages.

tests/integration/models/reddit/test_comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def test_edit(self, _):
6767
self.reddit.read_only = False
6868
with self.use_cassette():
6969
comment = Comment(self.reddit, "fwxxs5d")
70-
await comment.edit(body="New text")
70+
await comment.edit("New text")
7171
assert comment.body == "New text"
7272

7373
async def test_enable_inbox_replies(self):

tests/integration/models/reddit/test_submission.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def test_edit(self, _):
6666
self.reddit.read_only = False
6767
with self.use_cassette():
6868
submission = Submission(self.reddit, "hmkbt8")
69-
await submission.edit(body="New text")
69+
await submission.edit("New text")
7070
assert submission.selftext == "New text"
7171

7272
@mock.patch("asyncio.sleep", return_value=None)
@@ -76,7 +76,7 @@ async def test_edit_invalid(self, _):
7676
with self.use_cassette():
7777
submission = Submission(self.reddit, "hmkfoy")
7878
with pytest.raises(RedditAPIException):
79-
await submission.edit(body="rewtwert")
79+
await submission.edit("rewtwert")
8080

8181
async def test_enable_inbox_replies(self):
8282
self.reddit.read_only = False

0 commit comments

Comments
 (0)