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

Develop #629

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Develop #629

merged 2 commits into from
Sep 18, 2024

Conversation

PooyaFekri
Copy link
Collaborator

@PooyaFekri PooyaFekri commented Sep 18, 2024

Summary by Sourcery

Fix indexing issues in the is_following and be_followed_by methods to ensure correct retrieval of follower and following status.

Bug Fixes:

  • Fix incorrect indexing in the methods is_following and be_followed_by to correctly access the follower and following status.

Copy link
Contributor

sourcery-ai bot commented Sep 18, 2024

Reviewer's Guide by Sourcery

This pull request modifies the is_following and be_followed_by methods in the core/thirdpartyapp/farcaster.py file. The changes involve accessing specific keys from the dictionaries returned by the _get_followers_status and _get_follow_status methods.

File-Level Changes

Change Details Files
Updated return statements in is_following and be_followed_by methods to access specific dictionary keys
  • Modified is_following method to return self._get_followers_status(follower_fid, fid)[fid] instead of just self._get_followers_status(follower_fid, fid)
  • Modified be_followed_by method to return self._get_follow_status(fid, following_fid)[following_fid] instead of just self._get_follow_status(fid, following_fid)
core/thirdpartyapp/farcaster.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @PooyaFekri - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines 153 to +156
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid)
return self._get_follow_status(fid, following_fid)[following_fid]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Potential KeyError risk in dictionary access

The changes to is_following and be_followed_by methods now assume that _get_followers_status and _get_follow_status return dictionaries with specific keys. This could lead to KeyErrors if the expected keys are not present. Consider using the dict.get() method with a default value or checking for the key's existence before accessing it. Also, ensure that all code relying on these methods is updated to handle the new return type.

Suggested change
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid)
return self._get_follow_status(fid, following_fid)[following_fid]
return self._get_followers_status(follower_fid, fid).get(fid, False)
except (
RequestException,
IndexError,
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid).get(following_fid, False)

@PooyaFekri PooyaFekri merged commit 28e181a into main Sep 18, 2024
2 checks passed
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.

1 participant