Skip to content

Commit

Permalink
Merge edc9dcd into 79d3ba8
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonCoderAS committed Dec 28, 2019
2 parents 79d3ba8 + edc9dcd commit d95aa77
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions praw/models/reddit/modmail.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
"""Provide models for new modmail."""
from typing import Any, Dict, List, Optional, TypeVar

from ...const import API_PATH
from ...util import snake_case_keys
from .base import RedditBase

_ModmailConversation = TypeVar("_ModmailConversation")
Reddit = TypeVar("Reddit")


class ModmailConversation(RedditBase):
"""A class for modmail conversations.
Expand Down Expand Up @@ -90,7 +95,7 @@ def _convert_user_summary(data, reddit):

@classmethod
def parse( # pylint: disable=arguments-differ
cls, data, reddit, convert_objects=True
cls, data: Dict[str, Any], reddit: Reddit, convert_objects: bool = True
):
"""Return an instance of ModmailConversation from ``data``.
Expand Down Expand Up @@ -125,10 +130,10 @@ def parse( # pylint: disable=arguments-differ

def __init__(
self,
reddit,
id=None, # pylint: disable=redefined-builtin
mark_read=False,
_data=None,
reddit: Reddit,
id: Optional[str] = None, # pylint: disable=redefined-builtin
mark_read: bool = False,
_data: Optional[Dict[str, Any]] = None,
):
"""Construct an instance of the ModmailConversation object.
Expand Down Expand Up @@ -202,7 +207,9 @@ def mute(self):
"POST", API_PATH["modmail_mute"].format(id=self.id)
)

def read(self, other_conversations=None): # noqa: D207, D301
def read(
self, other_conversations: Optional[List[_ModmailConversation]] = None
): # noqa: D207, D301
"""Mark the conversation(s) as read.
:param other_conversations: A list of other conversations to mark
Expand All @@ -226,7 +233,9 @@ def read(self, other_conversations=None): # noqa: D207, D301
}
self._reddit.post(API_PATH["modmail_read"], data=data)

def reply(self, body, author_hidden=False, internal=False):
def reply(
self, body: str, author_hidden: bool = False, internal: bool = False
):
"""Reply to the conversation.
:param body: The Markdown formatted content for a message.
Expand Down Expand Up @@ -303,7 +312,9 @@ def unmute(self):
"POST", API_PATH["modmail_unmute"].format(id=self.id)
)

def unread(self, other_conversations=None): # noqa: D207, D301
def unread(
self, other_conversations: Optional[List[_ModmailConversation]] = None
): # noqa: D207, D301
"""Mark the conversation(s) as unread.
:param other_conversations: A list of other conversations to mark
Expand Down Expand Up @@ -334,7 +345,7 @@ class ModmailObject(RedditBase):
AUTHOR_ATTRIBUTE = "author"
STR_FIELD = "id"

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

0 comments on commit d95aa77

Please sign in to comment.