Refactor and update structure #20

Merged
Berack96 merged 22 commits from 16-refactoring-e-sanity-check into main 2025-10-08 16:21:10 +02:00
2 changed files with 7 additions and 9 deletions
Showing only changes of commit ef78f3b50c - Show all commits

View File

@@ -1,6 +1,6 @@
import os
from praw import Reddit # type: ignore
from praw.models import Submission, MoreComments # type: ignore
from praw.models import Submission # type: ignore
from app.base.social import SocialWrapper, SocialPost, SocialComment
@@ -28,16 +28,14 @@ def extract_post(post: Submission) -> SocialPost:
social.title = post.title
social.description = post.selftext
for i, top_comment in enumerate(post.comments.list()):
if i >= MAX_COMMENTS:
break
if isinstance(top_comment, MoreComments): #skip MoreComments objects
continue
for top_comment in post.comments:
comment = SocialComment()
comment.time = str(top_comment.created)
comment.description = top_comment.body
social.comments.append(comment)
if len(social.comments) >= MAX_COMMENTS:
break
return social
class RedditWrapper(SocialWrapper):

View File

@@ -51,7 +51,7 @@ class WrapperHandler(Generic[WrapperType]):
log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")
copilot-pull-request-reviewer[bot] commented 2025-10-05 19:33:31 +02:00 (Migrated from github.com)
Review

The variable 'error' is initialized but may be used uninitialized if no exception occurs in the while loop before the final raise statement.

The variable 'error' is initialized but may be used uninitialized if no exception occurs in the while loop before the final raise statement.
copilot-pull-request-reviewer[bot] commented 2025-10-05 21:18:36 +02:00 (Migrated from github.com)
Review

[nitpick] The variable 'error' is initialized but may not be used if no exceptions occur in the loop. Consider initializing it only when needed or using a more descriptive default value.


[nitpick] The variable 'error' is initialized but may not be used if no exceptions occur in the loop. Consider initializing it only when needed or using a more descriptive default value. ```suggestion ```
iterations = 0
error = ""
error = "No error"
while iterations < len(self.wrappers):
wrapper = self.wrappers[self.index]
wrapper_name = wrapper.__class__.__name__
@@ -92,7 +92,7 @@ class WrapperHandler(Generic[WrapperType]):
log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")
results: dict[str, OutputType] = {}
error = ""
error = "No error"
for wrapper in self.wrappers:
wrapper_name = wrapper.__class__.__name__
try: