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

Return only str in score property #634

Merged
merged 1 commit into from
Sep 21, 2024

Conversation

PooyaFekri
Copy link
Collaborator

@PooyaFekri PooyaFekri commented Sep 21, 2024

Summary by Sourcery

Modify the score property in the GitcoinPassportConnection class to return 0 when the score is None, ensuring consistent return type.

Bug Fixes:

  • Ensure the score property returns a default value of 0 when the score is None.

@PooyaFekri PooyaFekri merged commit b42eace into develop Sep 21, 2024
Copy link
Contributor

sourcery-ai bot commented Sep 21, 2024

Reviewer's Guide by Sourcery

This pull request modifies the score property of the GitcoinPassportConnection class to ensure it always returns a string value. The change handles the case where the submit_passport method might return None, replacing it with '0'.

File-Level Changes

Change Details Files
Modify score property to handle potential None return value
  • Replace direct return of _score with a conditional expression
  • Return '0' if _score is None
  • Return _score as-is if it's not None
authentication/models.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 - here's some feedback:

Overall Comments:

  • While handling the None case is good, consider logging a warning when _score is None to help identify potential issues with the submit_passport method. Also, evaluate whether 0 is the most appropriate default value in this context, or if a special 'no score' indicator might be more suitable.
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.

@@ -234,7 +234,7 @@ class GitcoinPassportConnection(BaseThirdPartyConnection):
@property
def score(self):
_score = self.driver.submit_passport(self.user_wallet_address)
return _score
return _score if _score is not None else 0
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider logging None case and document default value choice

While handling the None case is good, consider logging when _score is None as it might indicate an issue with submit_passport. Also, please document why 0 was chosen as the default value and ensure it's appropriate for your use case.

import logging

logger = logging.getLogger(__name__)

def score(self):
    _score = self.driver.submit_passport(self.user_wallet_address)
    if _score is None:
        logger.warning(f"submit_passport returned None for {self.user_wallet_address}")
        return 0
    return _score

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