Initialize the GitHub client Args: token: GitHub Personal Access Token, if None, try to get from environment variable
(self, token: Optional[str] = None)
| 7 | """GitHub operation client""" |
| 8 | |
| 9 | def __init__(self, token: Optional[str] = None): |
| 10 | """ |
| 11 | Initialize the GitHub client |
| 12 | |
| 13 | Args: |
| 14 | token: GitHub Personal Access Token, if None, try to get from environment variable |
| 15 | """ |
| 16 | self.token = token or os.getenv('GITHUB_AI_TOKEN') |
| 17 | if not self.token: |
| 18 | raise ValueError("GitHub Token is required, please provide it via the token parameter or set the GITHUB_AI_TOKEN environment variable.") |
| 19 | |
| 20 | self.session = requests.Session() |
| 21 | self.session.headers.update({ |
| 22 | 'Authorization': f'token {self.token}', |
| 23 | 'Accept': 'application/vnd.github.v3+json' |
| 24 | }) |
| 25 | self.api_base = 'https://api.github.com' |
| 26 | |
| 27 | def check_auth(self) -> dict: |
| 28 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected