Name | gh-util JSON |
Version |
0.1.16
JSON |
| download |
home_page | None |
Summary | Minimal LLM friendly Python client for GitHub API. |
upload_time | 2024-04-19 18:13:38 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
github
api
client
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# gh_util
A minimal Python library for interacting with GitHub's API, using `httpx` and `Pydantic`.
## **NOTE**
This library is under active development and will likely change.
## Installation
```bash
pip install gh_util
```
Either set `GH_UTIL_TOKEN` or `GITHUB_TOKEN` as an env var or in a `.env` file to enable authenticated requests and increase your rate limit.
## Usage
### Get the current user's GitHub profile
```python
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()))
```
<details>
<summary>Output</summary>
```python
# [01/22/24 00:23:18] DEBUG gh_util.client: AUTH: Using GitHub token set in environment via `GH_UTIL_TOKEN`
<ipython-input-1-8745118bb0ba>:12 <module>
asyncio.run(get_current_user()): GitHubUser(
login='zzstoatzz',
url=Url('https://api.github.com/users/zzstoatzz'),
id=31014960,
node_id='MDQ6VXNlcjMxMDE0OTYw',
avatar_url='https://avatars.githubusercontent.com/u/31014960?v=4',
gravatar_id='',
html_url='https://github.com/zzstoatzz',
followers_url='https://api.github.com/users/zzstoatzz/followers',
following_url='https://api.github.com/users/zzstoatzz/following{/other_user}',
gists_url='https://api.github.com/users/zzstoatzz/gists{/gist_id}',
starred_url='https://api.github.com/users/zzstoatzz/starred{/owner}{/repo}',
subscriptions_url='https://api.github.com/users/zzstoatzz/subscriptions',
organizations_url='https://api.github.com/users/zzstoatzz/orgs',
repos_url='https://api.github.com/users/zzstoatzz/repos',
events_url='https://api.github.com/users/zzstoatzz/events{/privacy}',
received_events_url='https://api.github.com/users/zzstoatzz/received_events',
type='User',
site_admin=False,
name='nate nowack',
company='@PrefectHQ ',
blog='askmarvin.ai',
location='Chicago, IL',
email='nate@prefect.io',
hireable=None,
bio=(
'data + software engineering @ Prefect\r\n'
'\r\n'
'building PrefectHQ/marvin'
),
twitter_username=None,
public_repos=52,
public_gists=23,
followers=47,
following=12,
created_at='2017-08-14T18:02:41Z',
updated_at='2024-01-17T14:34:54Z',
private_gists=15,
total_private_repos=6,
owned_private_repos=6,
disk_usage=179750,
collaborators=0,
two_factor_authentication=True,
plan={
'name': 'pro',
'space': 976562499,
'collaborators': 0,
'private_repos': 9999,
},
) (GitHubUser)
```
</details>
### Read a GitHub issue and its comments
```python
from gh_util.functions import fetch_repo_issue
from gh_util.print import print_repo_issue
async def main():
issue = await fetch_repo_issue("prefecthq", "marvin", 723, include_comments=True)
print_repo_issue(issue)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
```
<details>
<summary>Output</summary>
![read issue demo](docs/assets/gifs/gh-util-demo-read-issue.gif)
</details>
Raw data
{
"_id": null,
"home_page": null,
"name": "gh-util",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "github, api, client, python",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/28/95/09df6e9e5cc6840f6d85ee984d5ee3ce5b74a290aea0934aa3f481c66b5d/gh_util-0.1.16.tar.gz",
"platform": null,
"description": "# gh_util\n\nA minimal Python library for interacting with GitHub's API, using `httpx` and `Pydantic`.\n\n## **NOTE**\nThis library is under active development and will likely change.\n\n\n## Installation\n\n```bash\npip install gh_util\n```\n\nEither set `GH_UTIL_TOKEN` or `GITHUB_TOKEN` as an env var or in a `.env` file to enable authenticated requests and increase your rate limit.\n\n## Usage\n\n### Get the current user's GitHub profile\n```python\nfrom devtools import debug\nfrom gh_util.client import GHClient\nfrom gh_util.types import GitHubUser\n\nasync def get_current_user() -> GitHubUser:\n async with GHClient() as client:\n response = await client.get(\"/user\")\n return GitHubUser.model_validate(response.json())\n\nif __name__ == \"__main__\":\n import asyncio\n debug(asyncio.run(get_current_user()))\n```\n<details>\n<summary>Output</summary>\n\n```python\n# [01/22/24 00:23:18] DEBUG gh_util.client: AUTH: Using GitHub token set in environment via `GH_UTIL_TOKEN`\n<ipython-input-1-8745118bb0ba>:12 <module>\n asyncio.run(get_current_user()): GitHubUser(\n login='zzstoatzz',\n url=Url('https://api.github.com/users/zzstoatzz'),\n id=31014960,\n node_id='MDQ6VXNlcjMxMDE0OTYw',\n avatar_url='https://avatars.githubusercontent.com/u/31014960?v=4',\n gravatar_id='',\n html_url='https://github.com/zzstoatzz',\n followers_url='https://api.github.com/users/zzstoatzz/followers',\n following_url='https://api.github.com/users/zzstoatzz/following{/other_user}',\n gists_url='https://api.github.com/users/zzstoatzz/gists{/gist_id}',\n starred_url='https://api.github.com/users/zzstoatzz/starred{/owner}{/repo}',\n subscriptions_url='https://api.github.com/users/zzstoatzz/subscriptions',\n organizations_url='https://api.github.com/users/zzstoatzz/orgs',\n repos_url='https://api.github.com/users/zzstoatzz/repos',\n events_url='https://api.github.com/users/zzstoatzz/events{/privacy}',\n received_events_url='https://api.github.com/users/zzstoatzz/received_events',\n type='User',\n site_admin=False,\n name='nate nowack',\n company='@PrefectHQ ',\n blog='askmarvin.ai',\n location='Chicago, IL',\n email='nate@prefect.io',\n hireable=None,\n bio=(\n 'data + software engineering @ Prefect\\r\\n'\n '\\r\\n'\n 'building PrefectHQ/marvin'\n ),\n twitter_username=None,\n public_repos=52,\n public_gists=23,\n followers=47,\n following=12,\n created_at='2017-08-14T18:02:41Z',\n updated_at='2024-01-17T14:34:54Z',\n private_gists=15,\n total_private_repos=6,\n owned_private_repos=6,\n disk_usage=179750,\n collaborators=0,\n two_factor_authentication=True,\n plan={\n 'name': 'pro',\n 'space': 976562499,\n 'collaborators': 0,\n 'private_repos': 9999,\n },\n ) (GitHubUser)\n\n```\n</details>\n\n### Read a GitHub issue and its comments\n```python\nfrom gh_util.functions import fetch_repo_issue\nfrom gh_util.print import print_repo_issue\n\n\nasync def main():\n issue = await fetch_repo_issue(\"prefecthq\", \"marvin\", 723, include_comments=True)\n print_repo_issue(issue)\n\n\nif __name__ == \"__main__\":\n import asyncio\n\n asyncio.run(main())\n```\n\n<details>\n<summary>Output</summary>\n\n![read issue demo](docs/assets/gifs/gh-util-demo-read-issue.gif)\n\n</details>\n",
"bugtrack_url": null,
"license": null,
"summary": "Minimal LLM friendly Python client for GitHub API.",
"version": "0.1.16",
"project_urls": {
"Code": "https://github.com/zzstoatzz/gh"
},
"split_keywords": [
"github",
" api",
" client",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c5b7776397cd912a08b82f7898fdaed6bbd41467b96be27d7645aae3852232d8",
"md5": "80fc6cf63d296329dd214e7285bebd47",
"sha256": "21bd1a8b8071d7e987a402608d92b27b194aa04b1fdb8a08c24616f79879d682"
},
"downloads": -1,
"filename": "gh_util-0.1.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "80fc6cf63d296329dd214e7285bebd47",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 21081,
"upload_time": "2024-04-19T18:13:33",
"upload_time_iso_8601": "2024-04-19T18:13:33.800570Z",
"url": "https://files.pythonhosted.org/packages/c5/b7/776397cd912a08b82f7898fdaed6bbd41467b96be27d7645aae3852232d8/gh_util-0.1.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "289509df6e9e5cc6840f6d85ee984d5ee3ce5b74a290aea0934aa3f481c66b5d",
"md5": "8ba4dcd1164d1595a79c37265b374d37",
"sha256": "7cfbaca104edf48c7027bfa0c6ad38cbbf7d1d269c005ca297db89fd56973bd9"
},
"downloads": -1,
"filename": "gh_util-0.1.16.tar.gz",
"has_sig": false,
"md5_digest": "8ba4dcd1164d1595a79c37265b374d37",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10446034,
"upload_time": "2024-04-19T18:13:38",
"upload_time_iso_8601": "2024-04-19T18:13:38.716964Z",
"url": "https://files.pythonhosted.org/packages/28/95/09df6e9e5cc6840f6d85ee984d5ee3ce5b74a290aea0934aa3f481c66b5d/gh_util-0.1.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-19 18:13:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zzstoatzz",
"github_project": "gh",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "gh-util"
}