Skip to content

Commit 4e22468

Browse files
authored
Merge pull request #1688 from praw-dev/typing_improvments
Typing improvments
2 parents f487304 + c87b5f8 commit 4e22468

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

praw/models/mod_action.py

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

44
from .base import PRAWBase
55

@@ -16,5 +16,5 @@ def mod(self) -> "praw.models.Redditor":
1616
return self._reddit.redditor(self._mod) # pylint: disable=no-member
1717

1818
@mod.setter
19-
def mod(self, value: "praw.models.Redditor"):
19+
def mod(self, value: Union[str, "praw.models.Redditor"]):
2020
self._mod = value # pylint: disable=attribute-defined-outside-init

praw/models/reddit/comment.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
if TYPE_CHECKING: # pragma: no cover
1818
from .... import praw
19-
from ...reddit import models
2019

2120

2221
class Comment(InboxableMixin, UserContentMixin, FullnameMixin, RedditBase):
@@ -131,14 +130,14 @@ def replies(self) -> CommentForest:
131130
return self._replies
132131

133132
@property
134-
def submission(self) -> "models.Submission":
133+
def submission(self) -> "praw.models.Submission":
135134
"""Return the Submission object this comment belongs to."""
136135
if not self._submission: # Comment not from submission
137136
self._submission = self._reddit.submission(self._extract_submission_id())
138137
return self._submission
139138

140139
@submission.setter
141-
def submission(self, submission: "models.Submission"):
140+
def submission(self, submission: "praw.models.Submission"):
142141
"""Update the Submission associated with the Comment."""
143142
submission._comments_by_id[self.fullname] = self
144143
self._submission = submission
@@ -170,7 +169,7 @@ def __init__(
170169
def __setattr__(
171170
self,
172171
attribute: str,
173-
value: Union[str, "Redditor", "CommentForest", "models.subreddit.Subreddit"],
172+
value: Union[str, Redditor, CommentForest, "praw.models.Subreddit"],
174173
):
175174
"""Objectify author, replies, and subreddit."""
176175
if attribute == "author":
@@ -210,7 +209,7 @@ def _extract_submission_id(self):
210209
return self.context.rsplit("/", 4)[1]
211210
return self.link_id.split("_", 1)[1]
212211

213-
def parent(self) -> Union["praw.models.Comment", "praw.models.Submission"]:
212+
def parent(self) -> Union["Comment", "praw.models.Submission"]:
214213
"""Return the parent of the comment.
215214
216215
The returned parent will be an instance of either :class:`.Comment`, or

0 commit comments

Comments
 (0)