Skip to content

Commit

Permalink
Sort code
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Oct 20, 2023
1 parent 5956a62 commit 0d1c31f
Show file tree
Hide file tree
Showing 4 changed files with 2,988 additions and 2,988 deletions.
32 changes: 16 additions & 16 deletions asyncpraw/models/comment_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,6 @@ def __getitem__(self, index: int) -> asyncpraw.models.Comment:
raise TypeError(msg)
return self._comments[index]

def __init__(
self,
submission: asyncpraw.models.Submission,
comments: list[asyncpraw.models.Comment] | None = None,
):
"""Initialize a :class:`.CommentForest` instance.
:param submission: An instance of :class:`.Submission` that is the parent of the
comments.
:param comments: Initialize the forest with a list of comments (default:
``None``).
"""
self._comments = comments
self._submission = submission

def __len__(self) -> int:
"""Return the number of top-level comments in the forest."""
return len(self._comments or [])
Expand Down Expand Up @@ -181,6 +165,22 @@ async def async_func():
return async_func()
return comments

def __init__(
self,
submission: asyncpraw.models.Submission,
comments: list[asyncpraw.models.Comment] | None = None,
):
"""Initialize a :class:`.CommentForest` instance.
:param submission: An instance of :class:`.Submission` that is the parent of the
comments.
:param comments: Initialize the forest with a list of comments (default:
``None``).
"""
self._comments = comments
self._submission = submission

@_deprecate_args("limit", "threshold")
async def replace_more(
self, *, limit: int | None = 32, threshold: int = 0
Expand Down
26 changes: 13 additions & 13 deletions asyncpraw/models/reddit/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
import asyncpraw


class ModmailObject(RedditBase):
"""A base class for objects within a modmail conversation."""

AUTHOR_ATTRIBUTE = "author"
STR_FIELD = "id"

def __setattr__(self, attribute: str, value: Any):
"""Objectify the AUTHOR_ATTRIBUTE attribute."""
if attribute == self.AUTHOR_ATTRIBUTE:
value = self._reddit._objector.objectify(value)
super().__setattr__(attribute, value)


class ModmailConversation(RedditBase):
"""A class for modmail conversations.
Expand Down Expand Up @@ -340,19 +353,6 @@ async def unread(
await self._reddit.post(API_PATH["modmail_unread"], data=data)


class ModmailObject(RedditBase):
"""A base class for objects within a modmail conversation."""

AUTHOR_ATTRIBUTE = "author"
STR_FIELD = "id"

def __setattr__(self, attribute: str, value: Any):
"""Objectify the AUTHOR_ATTRIBUTE attribute."""
if attribute == self.AUTHOR_ATTRIBUTE:
value = self._reddit._objector.objectify(value)
super().__setattr__(attribute, value)


class ModmailAction(ModmailObject):
"""A class for moderator actions on modmail conversations."""

Expand Down
Loading

0 comments on commit 0d1c31f

Please sign in to comment.