-
Notifications
You must be signed in to change notification settings - Fork 23
Closed as not planned
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS: macOS 14.5
- Node.js version: v22.7.0
- npm version: 10.8.2
code-suggesterversion: 4.3.4
Steps to reproduce
You can recreate my PR at https://github.com/alvin-r/code-suggester-bug/pull/1/files.
- Create a PR, adding a new file with the name 'common_tags.py' with:
from __future__ import annotations
def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
if not articles:
return set()
common_tags = articles[0]["tags"]
for article in articles[1:]:
common_tags = [tag for tag in common_tags if tag in article["tags"]]
return set(common_tags)
- Use the reviewPullRequest. You can use this script:
import { Octokit } from "@octokit/rest"
import { reviewPullRequest } from "code-suggester"
async function reviewPR() {
// Initialize authenticated Octokit instance
const octokit = new Octokit({
auth: <YOUR_GITHUB_TOKEN>,
})
// Define the files to review with their changes
const diffContents = new Map()
diffContents.set("common_tags.py", {
oldContent: `from __future__ import annotations
def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
if not articles:
return set()
common_tags = articles[0]["tags"]
for article in articles[1:]:
common_tags = [tag for tag in common_tags if tag in article["tags"]]
return set(common_tags)`,
newContent: `from __future__ import annotations
def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
if not articles:
return set()
common_tags = set(articles[0]["tags"])
for article in articles[1:]:
common_tags.intersection_update(article["tags"])
return common_tags`,
})
// Configure review options
const options = {
owner: "alvin-r",
repo: "code-suggester-bug",
pullNumber: 1,
pageSize: 100,
}
try {
const result = await reviewPullRequest(octokit, diffContents, options)
console.log("Review completed:", result)
} catch (error) {
console.error("Review failed:", error)
}
}
reviewPR()
- When the review is created, the suggested code does not remove the 'return set(common_tags)' from the original code. You can see the comment created in https://github.com/alvin-r/code-suggester-bug/pull/1/files.
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.