mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-15 02:00:39 +08:00
Code adjustment to support calling is library
This commit is contained in:
@ -8,7 +8,8 @@ from atlassian.bitbucket import Cloud
|
||||
from starlette_context import context
|
||||
|
||||
from ..config_loader import get_settings
|
||||
from .git_provider import FilePatchInfo, GitProvider
|
||||
from .git_provider import GitProvider
|
||||
from ..algo.utils import FilePatchInfo
|
||||
|
||||
|
||||
class BitbucketProvider(GitProvider):
|
||||
|
@ -1,6 +1,9 @@
|
||||
import boto3
|
||||
import botocore
|
||||
|
||||
try: # Allow this module to be imported without requiring boto3
|
||||
import boto3
|
||||
import botocore
|
||||
except ModuleNotFoundError:
|
||||
boto3 = None
|
||||
botocore = None
|
||||
|
||||
class CodeCommitDifferencesResponse:
|
||||
"""
|
||||
|
@ -4,13 +4,12 @@ from collections import Counter
|
||||
from typing import List, Optional, Tuple
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from ..algo.language_handler import is_valid_file, language_extension_map
|
||||
from ..algo.pr_processing import clip_tokens
|
||||
from ..algo.utils import load_large_diff
|
||||
from ..config_loader import get_settings
|
||||
from .git_provider import EDIT_TYPE, FilePatchInfo, GitProvider, IncrementalPR
|
||||
from pr_agent.git_providers.codecommit_client import CodeCommitClient
|
||||
|
||||
from ..algo.language_handler import is_valid_file, language_extension_map
|
||||
from ..algo.utils import EDIT_TYPE, FilePatchInfo, load_large_diff
|
||||
from .git_provider import GitProvider
|
||||
|
||||
|
||||
class PullRequestCCMimic:
|
||||
"""
|
||||
|
@ -1,27 +1,9 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass
|
||||
|
||||
# enum EDIT_TYPE (ADDED, DELETED, MODIFIED, RENAMED)
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class EDIT_TYPE(Enum):
|
||||
ADDED = 1
|
||||
DELETED = 2
|
||||
MODIFIED = 3
|
||||
RENAMED = 4
|
||||
|
||||
|
||||
@dataclass
|
||||
class FilePatchInfo:
|
||||
base_file: str
|
||||
head_file: str
|
||||
patch: str
|
||||
filename: str
|
||||
tokens: int = -1
|
||||
edit_type: EDIT_TYPE = EDIT_TYPE.MODIFIED
|
||||
old_filename: str = None
|
||||
from pr_agent.algo.utils import FilePatchInfo
|
||||
|
||||
|
||||
class GitProvider(ABC):
|
||||
@ -87,7 +69,7 @@ class GitProvider(ABC):
|
||||
|
||||
def get_pr_description(self) -> str:
|
||||
from pr_agent.config_loader import get_settings
|
||||
from pr_agent.algo.pr_processing import clip_tokens
|
||||
from pr_agent.algo.utils import clip_tokens
|
||||
max_tokens = get_settings().get("CONFIG.MAX_DESCRIPTION_TOKENS", None)
|
||||
description = self.get_pr_description_full()
|
||||
if max_tokens:
|
||||
|
@ -9,10 +9,9 @@ from github import AppAuthentication, Auth, Github, GithubException, Reaction
|
||||
from retry import retry
|
||||
from starlette_context import context
|
||||
|
||||
from .git_provider import FilePatchInfo, GitProvider, IncrementalPR
|
||||
from .git_provider import GitProvider, IncrementalPR
|
||||
from ..algo.language_handler import is_valid_file
|
||||
from ..algo.utils import load_large_diff
|
||||
from ..algo.pr_processing import find_line_number_of_relevant_line_in_file, clip_tokens
|
||||
from ..algo.utils import load_large_diff, clip_tokens, find_line_number_of_relevant_line_in_file, FilePatchInfo
|
||||
from ..config_loader import get_settings
|
||||
from ..servers.utils import RateLimitExceeded
|
||||
|
||||
|
@ -7,10 +7,9 @@ import gitlab
|
||||
from gitlab import GitlabGetError
|
||||
|
||||
from ..algo.language_handler import is_valid_file
|
||||
from ..algo.pr_processing import clip_tokens
|
||||
from ..algo.utils import load_large_diff
|
||||
from ..algo.utils import load_large_diff, clip_tokens, EDIT_TYPE, FilePatchInfo
|
||||
from ..config_loader import get_settings
|
||||
from .git_provider import EDIT_TYPE, FilePatchInfo, GitProvider
|
||||
from .git_provider import GitProvider
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
@ -6,7 +6,8 @@ from typing import List
|
||||
from git import Repo
|
||||
|
||||
from pr_agent.config_loader import _find_repository_root, get_settings
|
||||
from pr_agent.git_providers.git_provider import EDIT_TYPE, FilePatchInfo, GitProvider
|
||||
from pr_agent.git_providers.git_provider import GitProvider
|
||||
from pr_agent.algo.utils import EDIT_TYPE, FilePatchInfo
|
||||
|
||||
|
||||
class PullRequestMimic:
|
||||
|
Reference in New Issue
Block a user