Minimal Python client for GitHub API.
Project description
gh_util
A minimal Python library for interacting with GitHub's API, using httpx
and Pydantic
.
Installation
pip install gh_util
Usage
Get the current user's GitHub profile
from devtools import debug
from gh_util.client import GHClient
from gh_util.types import GitHubUser
async def get_current_user() -> GitHubUser:
async with GHClient() as client:
response = await client.get("/user")
return GitHubUser.model_validate(response.json())
if __name__ == "__main__":
import asyncio
debug(asyncio.run(get_current_user()))
Read a GitHub issue and its comments
from gh_util.functions import fetch_github_issue
async def read_github_issue() -> None:
issue = await fetch_github_issue("prefecthq", "marvin", 723, include_comments=True)
print(f"[{issue.number} {issue.title}]({issue.url})")
print(issue.body)
for comment in issue.user_comments:
print(f"[{comment.user.login}]({comment.user.url}) said:")
print(f"{comment.body}")
if __name__ == "__main__":
import asyncio
asyncio.run(read_github_issue())
... and more at gh_util/functions.py
Development
git clone https://github.com/zzstoatzz/gh.git
cd gh
python -m venv gh_util
source gh_util/bin/activate
pip install -e .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gh_util-0.1.0a9.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for gh_util-0.1.0a9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a3340ff3e4b32770eb4a897b56d73300b86d7859078ef52d088afbb85f1277c |
|
MD5 | ec126cf8c22bad56a8a4c8061b575f69 |
|
BLAKE2b-256 | b480858c108d2af0f96e64ef61048a1cf37ddd02527b017b6bf67f5f46558863 |