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

fix conflict #43

Open
wants to merge 1 commit into
base: old/main
Choose a base branch
from
Open

fix conflict #43

wants to merge 1 commit into from

Conversation

gitworkflows
Copy link
Contributor

@gitworkflows gitworkflows commented Aug 13, 2024

Description

This PR fixes #

Notes for Reviewers

Signed commits

  • [*] Yes, I signed my commits.

Summary by Sourcery

Fix variable name conflict by renaming 'action' to 'action_type' in functions handling GitHub PR events to avoid ambiguity and potential errors.

Bug Fixes:

  • Fix variable name conflict by renaming 'action' to 'action_type' across multiple functions handling GitHub PR events.

Copy link
Contributor

sourcery-ai bot commented Aug 13, 2024

Reviewer's Guide by Sourcery

This pull request primarily focuses on renaming the 'action' parameter to 'action_type' throughout the 'github_app.py' file. This change is implemented consistently across multiple functions and affects how GitHub events are handled and logged. The PR also includes minor adjustments to error logging and function calls to accommodate this parameter name change.

File-Level Changes

Files Changes
pr_action/servers/github_app.py Renamed 'action' parameter to 'action_type' in function signatures and method calls
pr_action/servers/github_app.py Updated variable references from 'action' to 'action_type' within function bodies
pr_action/servers/github_app.py Modified log messages to use 'action_type' instead of 'action'
pr_action/servers/github_app.py Updated the 'get_log_context' function to use 'action_type' in the returned dictionary
pr_action/servers/github_app.py Adjusted conditional statements to check 'action_type' instead of 'action'

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

Failed to generate code suggestions for PR

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 @gitworkflows - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider maintaining consistency in the renaming of 'action' to 'action_type'. There are still some instances where 'action' is used, such as in the _perform_auto_commands_github call.
  • While this change addresses the immediate naming conflict, consider if there's a more fundamental way to improve the code structure. The high number of parameters in some functions might indicate an opportunity for refactoring.
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.

@@ -80,7 +80,7 @@ async def handle_comments_on_pr(body: Dict[str, Any],
event: str,
sender: str,
sender_id: str,
action: str,
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 a more comprehensive solution for the 'action' vs 'action_type' naming conflict

The renaming of 'action' to 'action_type' addresses the immediate naming conflict but introduces inconsistency and potential confusion. Consider the following improvements:

  1. Evaluate if the 'action: PRAction' parameter is necessary in all functions. Remove it where it's not needed to eliminate the naming conflict.
  2. Ensure consistency across the file. Some functions (e.g., 'handle_closed_pr', 'get_log_context') use 'action_type', while others (e.g., '_perform_auto_commands_github') still use 'action'.
  3. Update the docstring for 'handle_request' function to reflect the change from 'action' to 'action_type'.
  4. Review the usage of 'action = PRAction()' in the 'handle_request' function, as it seems inconsistent with the renaming.
  5. Consider making the error log message in 'handle_request' more informative while updating it to use 'action_type'.
    A more thorough refactoring could improve code clarity and maintainability.
                                action_type: str,
                                pr_action: PRAction,

@@ -319,7 +319,7 @@
log_context["api_url"] = api_url
if pull_request.get("draft", True) or pull_request.get("state") != "open":
return invalid_result
if action in ("review_requested", "synchronize") and pull_request.get("created_at") == pull_request.get("updated_at"):
if action_type in ("review_requested", "synchronize") and pull_request.get("created_at") == pull_request.get("updated_at"):
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Use set when checking membership of a collection of literals (collection-into-set)

Suggested change
if action_type in ("review_requested", "synchronize") and pull_request.get("created_at") == pull_request.get("updated_at"):
if action_type in {"review_requested", "synchronize"} and pull_request.get(
"created_at"
) == pull_request.get("updated_at"):

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