Skip to content

Commit

Permalink
Merge pull request #216 from praw-dev/positional_argument_reverts
Browse files Browse the repository at this point in the history
Revert `EditableMixin.edit` positional argument deprecation
  • Loading branch information
LilSpazJoekp committed Nov 28, 2022
2 parents 38f2238 + bb8c7a7 commit a381420
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,11 @@ Async PRAW follows `semantic versioning <http://semver.org/>`_.
Unreleased
----------

**Changed**

- Revert :meth:`~.Comment.edit` positional argument deprecation.
- Revert :meth:`~.Submission.edit` positional argument deprecation.

**Fixed**

- An issue where :class:`.ModmailConversation`'s ``messages`` attribute would only
Expand Down
6 changes: 2 additions & 4 deletions asyncpraw/models/reddit/mixins/editable.py
Expand Up @@ -2,7 +2,6 @@
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 @@ -27,9 +26,8 @@ async def delete(self):
"""
await self._reddit.post(API_PATH["del"], data={"id": self.fullname})

@_deprecate_args("body")
async def edit(
self, *, body: str
self, body: str
) -> Union["asyncpraw.models.Comment", "asyncpraw.models.Submission"]:
"""Replace the body of the object with ``body``.
Expand All @@ -46,7 +44,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(body=edited_body)
await comment.edit(edited_body)
"""
data = {
Expand Down
10 changes: 6 additions & 4 deletions asyncpraw/models/reddit/mixins/replyable.py
@@ -1,5 +1,5 @@
"""Provide the ReplyableMixin class."""
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING, Optional, Union

from ....const import API_PATH

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

async def reply(self, body: str) -> Optional["asyncpraw.models.Comment"]:
async def reply(
self, body: str
) -> Optional[Union["asyncpraw.models.Comment", "asyncpraw.models.Message"]]:
"""Reply to the object.
:param body: The Markdown formatted content for a comment.
:returns: A :class:`.Comment` object for the newly created comment or ``None``
if Reddit doesn't provide one.
:returns: A :class:`.Comment` or :class:`.Message` object for the newly created
comment or message or ``None`` if Reddit doesn't provide one.
:raises: ``asyncprawcore.exceptions.Forbidden`` when attempting to reply to some
items, such as locked submissions/comments or non-replyable messages.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/models/reddit/test_comment.py
Expand Up @@ -67,7 +67,7 @@ async def test_edit(self, _):
self.reddit.read_only = False
with self.use_cassette():
comment = Comment(self.reddit, "fwxxs5d")
await comment.edit(body="New text")
await comment.edit("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 @@ -66,7 +66,7 @@ async def test_edit(self, _):
self.reddit.read_only = False
with self.use_cassette():
submission = Submission(self.reddit, "hmkbt8")
await submission.edit(body="New text")
await submission.edit("New text")
assert submission.selftext == "New text"

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

async def test_enable_inbox_replies(self):
self.reddit.read_only = False
Expand Down

0 comments on commit a381420

Please sign in to comment.