Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert self.id to str to make it iterable #1760

Closed
wants to merge 1 commit into from

Conversation

Demmenie
Copy link

@Demmenie Demmenie commented Jul 14, 2021

This function was creating a TypeError outlined in issue #1759. This should fix that (I hope)

Fixes #1759

This function was creating a TypeError outlined in issue praw-dev#1759. This should fix that (I hope)
@MaybeNetwork
Copy link
Contributor

In your linked issue, you ran the code

reddit.comment(id=comment).author.name

This means that you're taking an existing comment, constructing an entirely new comment instance with the id of the new comment set to the old comment itself, and then checking the name of the author of the new comment. This is equivalent to doing the following:

comment1=reddit.comment(id='h56nm42')
comment2=reddit.comment(id=comment1)
comment2.author.name

When you go to fetch the comment, fetch_info calls the fullname method, which tries to see if _ is in the Comment object, which is not iterable. The change you made works for your case because calls str on the comment object, which retrieves a string with the comment id, which is iterable. However, the change seems to be causing another test to fail.

In the mean time, you could just call comment1.author.name to retrieve the name. The id passed to the comment object is supposed to be a string, not a comment—see the type annotation.

@LilSpazJoekp
Copy link
Member

However, the change seems to be causing another test to fail.

This is interesting because the test that failed has nothing to do with full names and the error doesn't make any sense.

@bboe
Copy link
Member

bboe commented Jul 15, 2021

Closing this PR as the associated issue describes the preferred solution. Thanks for looking into a potential issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: argument of type 'Comment' is not iterable
4 participants