{"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pr-commenter"],"cli":null},"imports":["from pr_commenter.pr_commenter import PRCommenter"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}