sweepai / sweep

Sweep: open-source AI-powered Software Developer for small features and bug fixes.
https://sweep.dev
Other
7.39k stars 419 forks source link

Sweep: remove unnecessary imports in on_ticket #3645

Closed kevinlu1248 closed 4 months ago

kevinlu1248 commented 4 months ago

Branch

No response

Checklist - [ ] ``sweepai/handlers/on_ticket.py``
sweep-nightly[bot] commented 4 months ago
Sweeping

✨ Track Sweep's progress on our progress dashboard!


50%
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: fd39ba0d37)

[!TIP] I can email you when I complete this pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/sweepai/sweep/blob/f32377cfa66afb02b9934ce0b1ae1826d2752c71/sweepai/handlers/on_ticket.py#L1-L1911

Step 2: ⌨️ Coding

import difflib import io import os import re import traceback from typing import Any import zipfile from time import time import markdown import openai import requests import yaml import yamllint.config as yamllint_config from github import BadCredentialsException, Github, Repository from github.Issue import Issue from github.PullRequest import PullRequest as GithubPullRequest from loguru import logger from tabulate import tabulate from tqdm import tqdm from yamllint import linter from sweepai.agents.pr_description_bot import PRDescriptionBot from sweepai.agents.image_description_bot import ImageDescriptionBot from sweepai.config.client import ( DEFAULT_RULES, RESET_FILE, RESTART_SWEEP_BUTTON, REVERT_CHANGED_FILES_TITLE, RULES_LABEL, RULES_TITLE, SWEEP_BAD_FEEDBACK, SWEEP_GOOD_FEEDBACK, SweepConfig, get_documentation_dict, get_gha_enabled, get_rules, ) from sweepai.config.server import ( DEPLOYMENT_GHA_ENABLED, DISCORD_FEEDBACK_WEBHOOK_URL, ENV, GITHUB_LABEL_NAME, IS_SELF_HOSTED, MONGODB_URI, PROGRESS_BASE_URL, ) from sweepai.core.entities import ( AssistantRaisedException, FileChangeRequest, MaxTokensExceeded, NoFilesException, PullRequest, SandboxResponse, ) from sweepai.core.entities import create_error_logs as entities_create_error_logs from sweepai.core.pr_reader import PRReader from sweepai.core.sweep_bot import SweepBot, get_files_to_change, validate_file_change_requests from sweepai.handlers.create_pr import ( create_config_pr, create_pr_changes, safe_delete_sweep_branch, ) from sweepai.handlers.on_check_suite import clean_gh_logs from sweepai.utils.image_utils import get_image_contents_from_urls, get_image_urls_from_issue from sweepai.utils.validate_license import validate_license from sweepai.utils.buttons import Button, ButtonList, create_action_buttons from sweepai.utils.chat_logger import ChatLogger from sweepai.utils.diff import generate_diff from sweepai.utils.event_logger import posthog from sweepai.utils.github_utils import ( CURRENT_USERNAME, ClonedRepo, convert_pr_draft_field, get_github_client, get_token, sanitize_string_for_github, ) from sweepai.utils.progress import ( AssistantConversation, PaymentContext, TicketContext, TicketProgress, TicketProgressStatus, ) from sweepai.utils.prompt_constructor import HumanMessagePrompt from sweepai.utils.str_utils import ( BOT_SUFFIX, FASTER_MODEL_MESSAGE, UPDATES_MESSAGE, blockquote, bot_suffix, checkbox_template, clean_logs, collapsible_template, create_checkbox, create_collapsible, discord_suffix, format_sandbox_success, get_hash, sep, stars_suffix, strip_sweep, to_branch_name, ) import os import re import traceback from typing import Any from time import time import openai import yaml from github import BadCredentialsException, Github, Repository from github.Issue import Issue from github.PullRequest import PullRequest as GithubPullRequest from loguru import logger from sweepai.config.client import ( DEFAULT_RULES, RESET_FILE, RESTART_SWEEP_BUTTON, REVERT_CHANGED_FILES_TITLE, RULES_LABEL, RULES_TITLE, SWEEP_BAD_FEEDBACK, SWEEP_GOOD_FEEDBACK, SweepConfig, get_gha_enabled, get_rules, ) from sweepai.config.server import ( DEPLOYMENT_GHA_ENABLED, DISCORD_FEEDBACK_WEBHOOK_URL, ENV, GITHUB_LABEL_NAME, IS_SELF_HOSTED, MONGODB_URI, PROGRESS_BASE_URL, ) from sweepai.core.entities import ( AssistantRaisedException, FileChangeRequest, MaxTokensExceeded, NoFilesException, PullRequest, SandboxResponse, ) from sweepai.core.entities import create_error_logs as entities_create_error_logs from sweepai.core.pr_reader import PRReader from sweepai.core.sweep_bot import SweepBot, get_files_to_change, validate_file_change_requests from sweepai.handlers.create_pr import ( create_config_pr, create_pr_changes, safe_delete_sweep_branch, ) from sweepai.utils.image_utils import get_image_contents_from_urls, get_image_urls_from_issue from sweepai.utils.validate_license import validate_license from sweepai.utils.buttons import Button, ButtonList, create_action_buttons from sweepai.utils.chat_logger import ChatLogger from sweepai.utils.event_logger import posthog from sweepai.utils.github_utils import ( CURRENT_USERNAME, ClonedRepo, convert_pr_draft_field, get_github_client, get_token, sanitize_string_for_github, ) from sweepai.utils.progress import ( AssistantConversation, PaymentContext, TicketContext, TicketProgress, TicketProgressStatus, ) from sweepai.utils.prompt_constructor import HumanMessagePrompt from sweepai.utils.str_utils import ( BOT_SUFFIX, FASTER_MODEL_MESSAGE, UPDATES_MESSAGE, blockquote, bot_suffix, checkbox_template, clean_logs, collapsible_template, create_checkbox, create_collapsible, discord_suffix, format_sandbox_success, get_hash, sep, stars_suffix, strip_sweep, to_branch_name, )

After reviewing the imports, the following unused imports were removed:

All other imports are used within the on_ticket function and should be kept.


Step 3: 🔁 Code Review

Working on it...


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.