fix errors found by Copilot

This commit is contained in:
2025-10-05 21:17:38 +02:00
parent f5816bb74f
commit ef78f3b50c
2 changed files with 7 additions and 9 deletions

View File

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

View File

@@ -51,7 +51,7 @@ class WrapperHandler(Generic[WrapperType]):
log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}") log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")
iterations = 0 iterations = 0
error = "" error = "No error"
while iterations < len(self.wrappers): while iterations < len(self.wrappers):
wrapper = self.wrappers[self.index] wrapper = self.wrappers[self.index]
wrapper_name = wrapper.__class__.__name__ wrapper_name = wrapper.__class__.__name__
@@ -92,7 +92,7 @@ class WrapperHandler(Generic[WrapperType]):
log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}") log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")
results: dict[str, OutputType] = {} results: dict[str, OutputType] = {}
error = "" error = "No error"
for wrapper in self.wrappers: for wrapper in self.wrappers:
wrapper_name = wrapper.__class__.__name__ wrapper_name = wrapper.__class__.__name__
try: try: