mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 21:00:40 +08:00
Remove redundant None default in dict.get
This commit is contained in:
@ -70,7 +70,7 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
body: The request body.
|
body: The request body.
|
||||||
event: The GitHub event type.
|
event: The GitHub event type.
|
||||||
"""
|
"""
|
||||||
action = body.get("action", None)
|
action = body.get("action")
|
||||||
if not action:
|
if not action:
|
||||||
return {}
|
return {}
|
||||||
agent = PRAgent()
|
agent = PRAgent()
|
||||||
@ -85,8 +85,8 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
if action == 'created':
|
if action == 'created':
|
||||||
if "comment" not in body:
|
if "comment" not in body:
|
||||||
return {}
|
return {}
|
||||||
comment_body = body.get("comment", {}).get("body", None)
|
comment_body = body.get("comment", {}).get("body")
|
||||||
sender = body.get("sender", {}).get("login", None)
|
sender = body.get("sender", {}).get("login")
|
||||||
if sender and bot_user in sender:
|
if sender and bot_user in sender:
|
||||||
logging.info(f"Ignoring comment from {bot_user} user")
|
logging.info(f"Ignoring comment from {bot_user} user")
|
||||||
return {}
|
return {}
|
||||||
@ -106,19 +106,19 @@ async def handle_request(body: Dict[str, Any], event: str):
|
|||||||
# automatically review opened/reopened/ready_for_review PRs as long as they're not in draft,
|
# automatically review opened/reopened/ready_for_review PRs as long as they're not in draft,
|
||||||
# as well as direct review requests from the bot
|
# as well as direct review requests from the bot
|
||||||
elif event == 'pull_request':
|
elif event == 'pull_request':
|
||||||
pull_request = body.get("pull_request", None)
|
pull_request = body.get("pull_request")
|
||||||
if not pull_request:
|
if not pull_request:
|
||||||
return {}
|
return {}
|
||||||
api_url = pull_request.get("url", None)
|
api_url = pull_request.get("url")
|
||||||
if api_url is None:
|
if not api_url:
|
||||||
return {}
|
return {}
|
||||||
if pull_request.get("draft", True) or pull_request.get("state", None) != "open" or pull_request.get("user", {}).get("login", "") == bot_user:
|
if pull_request.get("draft", True) or pull_request.get("state") != "open" or pull_request.get("user", {}).get("login", "") == bot_user:
|
||||||
return {}
|
return {}
|
||||||
if action in get_settings().github_app.handle_pr_actions:
|
if action in get_settings().github_app.handle_pr_actions:
|
||||||
if action == "review_requested":
|
if action == "review_requested":
|
||||||
if body.get("requested_reviewer", {}).get("login", "") != bot_user:
|
if body.get("requested_reviewer", {}).get("login", "") != bot_user:
|
||||||
return {}
|
return {}
|
||||||
if pull_request.get("created_at", None) == pull_request.get("updated_at", None):
|
if pull_request.get("created_at") == pull_request.get("updated_at"):
|
||||||
# avoid double reviews when opening a PR for the first time
|
# avoid double reviews when opening a PR for the first time
|
||||||
return {}
|
return {}
|
||||||
logging.info(f"Performing review because of event={event} and action={action}")
|
logging.info(f"Performing review because of event={event} and action={action}")
|
||||||
|
Reference in New Issue
Block a user