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)
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()
Environment details
code-suggesterversion: 4.3.4Steps to reproduce
You can recreate my PR at https://github.com/alvin-r/code-suggester-bug/pull/1/files.