{"id":10057,"library":"pr-commenter","title":"PR Commenter","description":"PR Commenter is a Python library that simplifies the process of adding, updating, and removing automated comments on GitHub Pull Requests. It leverages PyGithub to interact with the GitHub API, providing a clean interface for managing discussion threads. The current version is 0.2.4, and releases are generally made on an 'as-needed' basis, with a focus on stability for its core functionality.","status":"active","version":"0.2.4","language":"python","source_language":"en","source_url":"https://github.com/dkhunt/pr-commenter","tags":["github","pull-request","automation","commenting","ci"],"install":[{"cmd":"pip install pr-commenter","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for interacting with the GitHub API.","package":"PyGithub","optional":false}],"imports":[{"wrong":"from pr_commenter import PRCommenter","symbol":"PRCommenter","correct":"from pr_commenter import PRCommenter"}],"quickstart":{"code":"import os\nfrom pr_commenter.pr_commenter import PRCommenter\nfrom github import Github\n\n# Ensure GITHUB_TOKEN is set as an environment variable with 'repo' scope\ngithub_token = os.environ.get('GITHUB_TOKEN', '')\nif not github_token:\n    raise ValueError(\"GITHUB_TOKEN environment variable not set.\")\n\ng = Github(github_token)\n\n# Replace with your actual repository and PR number\nrepo_name = \"octocat/Spoon-Knife\" # Example: 'your_user/your_repo_name'\npr_number = 1 # Example: your PR number\n\ntry:\n    repo = g.get_repo(repo_name)\n    pr = repo.get_pull(pr_number)\n    pc = PRCommenter(pr)\n\n    # Add a new comment\n    comment_id = \"my_unique_automation_id_123\"\n    print(f\"Adding/Updating comment with ID: {comment_id}\")\n    pc.add_comment(\"This is an automated comment.\", comment_id)\n\n    # Update an existing comment\n    pc.update_comment(\"This is an UPDATED automated comment.\", comment_id)\n\n    # Remove a comment\n    # pc.remove_comment(comment_id)\n\n    print(\"PR Commenter operations completed.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize `PRCommenter` and use its primary methods: `add_comment`, `update_comment`, and `remove_comment`. It requires a GitHub Personal Access Token with appropriate 'repo' scope permissions, passed via the `GITHUB_TOKEN` environment variable, to interact with your repository and pull requests."},"warnings":[{"fix":"Always use a unique `comment_id` when initially adding a comment. Ensure the `comment_id` passed to `update_comment` or `remove_comment` exactly matches the ID of the target comment.","message":"The `comment_id` parameter is crucial for managing automated comments. If you reuse the same `comment_id` with `add_comment`, it will create duplicate comments instead of updating existing ones. `update_comment` and `remove_comment` rely on this ID to find the correct comment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Generate a GitHub PAT with the 'repo' scope (or at least specific write permissions for pull requests/issues). Store it securely (e.g., as an environment variable `GITHUB_TOKEN`) and ensure it's provided to the `github.Github` constructor.","message":"GitHub Personal Access Tokens (PATs) used with `PyGithub` and `pr-commenter` must have sufficient permissions. Typically, the 'repo' scope is required to create, update, and delete comments on pull requests.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Maintain a record of the `comment_id`s used for your automated comments. To remove multiple, loop through your stored IDs and call `pc.remove_comment(id)` for each.","message":"There is no built-in `remove_all_comments` method for all comments added by the `PRCommenter` instance. If you need to remove multiple automated comments, you must iterate through them and call `remove_comment` for each `comment_id`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.2.4':45 'ad':14 'api':32 'as-need':53 'autom':18,70 'basi':56 'ci':72 'clean':35 'comment':2,4,19,71 'core':64 'current':42 'discuss':39 'focus':59 'function':65 'general':49 'github':21,31,66 'interact':28 'interfac':36 'leverag':25 'librari':8 'made':50 'manag':38 'need':55 'pr':1,3 'process':12 'provid':33 'pull':22,68 'pull-request':67 'pygithub':26 'python':7 'releas':47 'remov':17 'request':23,69 'simplifi':10 'stabil':61 'thread':40 'updat':15 'version':43","created_at":"2026-04-17T01:22:09.842735+00:00","updated_at":"2026-04-17T01:22:09.842735+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'PRCommenter' from 'pr_commenter' (/tmp/tmpf6sg51uj/venv/lib/python3.12/site-packages/pr_commenter.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.4","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Shiphero/pr-commenter","docs":null,"changelog":"https://github.com/Shiphero/pr-commenter/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/pr-commenter/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}