Skip to content

Commit 9132f13

Browse files
authored
feat: final set of upgrades for tools (#604)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed --------- Co-authored-by: kopekC <[email protected]>
1 parent 9590dce commit 9132f13

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/codegen/extensions/tools/github/view_pr.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ViewPRObservation(Observation):
2121
file_commit_sha: dict[str, str] = Field(
2222
description="Commit SHAs for each file in the PR",
2323
)
24+
modified_symbols: list[str] = Field(
25+
description="Names of modified symbols in the PR",
26+
)
2427

2528
str_template: ClassVar[str] = "PR #{pr_id}"
2629

@@ -33,13 +36,14 @@ def view_pr(codebase: Codebase, pr_id: int) -> ViewPRObservation:
3336
pr_id: Number of the PR to get the contents for
3437
"""
3538
try:
36-
patch, file_commit_sha = codebase.get_modified_symbols_in_pr(pr_id)
39+
patch, file_commit_sha, moddified_symbols = codebase.get_modified_symbols_in_pr(pr_id)
3740

3841
return ViewPRObservation(
3942
status="success",
4043
pr_id=pr_id,
4144
patch=patch,
4245
file_commit_sha=file_commit_sha,
46+
modified_symbols=moddified_symbols,
4347
)
4448

4549
except Exception as e:
@@ -49,4 +53,5 @@ def view_pr(codebase: Codebase, pr_id: int) -> ViewPRObservation:
4953
pr_id=pr_id,
5054
patch="",
5155
file_commit_sha={},
56+
modified_symbols=[],
5257
)

src/codegen/git/utils/pr_review.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from codegen.git.repo_operator.repo_operator import RepoOperator
1010

1111
if TYPE_CHECKING:
12-
from codegen.sdk.core.codebase import Codebase, Editable, File, Symbol
12+
from codegen.sdk.core.codebase import Codebase, Editable, File
1313

1414

1515
def get_merge_base(git_repo_client: Repository, pull: PullRequest | PullRequestContext) -> str:
@@ -150,7 +150,7 @@ def is_modified(self, editable: "Editable") -> bool:
150150
return False
151151

152152
@property
153-
def modified_symbols(self) -> list["Symbol"]:
153+
def modified_symbols(self) -> list[str]:
154154
# Import SourceFile locally to avoid circular dependencies
155155
from codegen.sdk.core.file import SourceFile
156156

@@ -163,7 +163,8 @@ def modified_symbols(self) -> list["Symbol"]:
163163
continue
164164
for symbol in file.symbols:
165165
if self.is_modified(symbol):
166-
all_modified.append(symbol)
166+
all_modified.append(symbol.name)
167+
167168
return all_modified
168169

169170
def get_pr_diff(self) -> str:

src/codegen/sdk/core/codebase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,13 +1311,13 @@ def from_repo(
13111311
logger.exception(f"Failed to initialize codebase: {e}")
13121312
raise
13131313

1314-
def get_modified_symbols_in_pr(self, pr_id: int) -> tuple[str, dict[str, str]]:
1314+
def get_modified_symbols_in_pr(self, pr_id: int) -> tuple[str, dict[str, str], list[str]]:
13151315
"""Get all modified symbols in a pull request"""
13161316
pr = self._op.get_pull_request(pr_id)
13171317
cg_pr = CodegenPR(self._op, self, pr)
13181318
patch = cg_pr.get_pr_diff()
13191319
commit_sha = cg_pr.get_file_commit_shas()
1320-
return patch, commit_sha
1320+
return patch, commit_sha, cg_pr.modified_symbols
13211321

13221322
def create_pr_comment(self, pr_number: int, body: str) -> None:
13231323
"""Create a comment on a pull request"""

0 commit comments

Comments
 (0)