Repository: praw-dev/praw

Issue:
Usage of assert
These assert values should be added or updated with a message to explain what went wrong. 

- [ ] praw/objector.py: Line 40 has phrase assert, please edit and remove this.
- [ ] praw/objector.py: Line 171 has phrase assert, please edit and remove this.
- [x] praw/models/comment_forest.py: Line 82 has phrase assert, please edit and remove this.
- [x] praw/models/trophy.py: Line 45 has phrase assert, please edit and remove this.
- [x] praw/models/reddit/redditor.py: Line 141 has phrase assert, please edit and remove this.
- [x] praw/models/reddit/widgets.py: Line 1403 has phrase assert, please edit and remove this.
- [x] praw/models/reddit/subreddit.py: Line 2774 has phrase assert, please edit and remove this.
- [ ] praw/models/reddit/more.py: Line 48 has phrase assert, please edit and remove this.
- [ ] praw/models/reddit/more.py: Line 67 has phrase assert, please edit and remove this.
- [ ] praw/models/reddit/more.py: Line 75 has phrase assert, please edit and remove this.



Discussion:

Resolving patch:
diff --git a/praw/models/reddit/more.py b/praw/models/reddit/more.py
--- a/praw/models/reddit/more.py
+++ b/praw/models/reddit/more.py
@@ -45,7 +45,7 @@ def __repr__(self) -> str:
         )
 
     def _continue_comments(self, update):
-        assert not self.children
+        assert not self.children, "Please file a bug report with PRAW."
         parent = self._load_comment(self.parent_id.split("_", 1)[1])
         self._comments = parent.replies
         if update:
@@ -64,7 +64,9 @@ def _load_comment(self, comment_id):
                 "sort": self.submission.comment_sort,
             },
         )
-        assert len(comments.children) == 1
+        assert (
+            len(comments.children) == 1
+        ), "Please file a bug report with PRAW."
         return comments.children[0]
 
     def comments(self, update: bool = True) -> List[Comment]:
@@ -72,7 +74,7 @@ def comments(self, update: bool = True) -> List[Comment]:
         if self._comments is None:
             if self.count == 0:  # Handle 'continue this thread'
                 return self._continue_comments(update)
-            assert self.children
+            assert self.children, "Please file a bug report with PRAW."
             data = {
                 "children": ",".join(self.children),
                 "link_id": self.submission.fullname,
diff --git a/praw/objector.py b/praw/objector.py
--- a/praw/objector.py
+++ b/praw/objector.py
@@ -35,11 +35,10 @@ def parse_error(
         if len(errors) < 1:
             # See `Collection._fetch()`.
             raise ClientException("successful error response", data)
-        if len(errors) > 1:
-            # Yet to be observed.
-            raise AssertionError(
-                "multiple error descriptions in response", data
-            )
+        assert not len(errors) > 1, (  # Yet to be observed.
+            "multiple error descriptions in response",
+            data,
+        )
 
         return APIException(*errors[0])
 
@@ -168,7 +167,10 @@ def objectify(
             errors = data["json"]["errors"]
             if len(errors) == 1:
                 raise APIException(*errors[0])
-            assert not errors
+            assert not errors, (
+                "Errors did not get raised as an APIException",
+                errors,
+            )
         elif isinstance(data, dict):
             return self._objectify_dict(data)
 


Test patch: