gitcode-api 1.0.3__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/PKG-INFO +33 -17
  2. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/README.md +30 -13
  3. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/_client.py +6 -0
  4. gitcode_api-1.1.1/gitcode_api/_models.py +3076 -0
  5. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/resources/_shared.py +65 -12
  6. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/resources/account.py +302 -53
  7. gitcode_api-1.1.1/gitcode_api/resources/collaboration.py +2453 -0
  8. gitcode_api-1.1.1/gitcode_api/resources/misc.py +578 -0
  9. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/resources/repositories.py +606 -123
  10. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api.egg-info/PKG-INFO +33 -17
  11. gitcode_api-1.1.1/gitcode_api.egg-info/requires.txt +1 -0
  12. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/pyproject.toml +4 -5
  13. gitcode_api-1.1.1/tests/test_client.py +89 -0
  14. gitcode_api-1.1.1/tests/test_models.py +31 -0
  15. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/tests/test_resources_account.py +5 -5
  16. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/tests/test_resources_collaboration.py +38 -5
  17. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/tests/test_resources_misc.py +3 -2
  18. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/tests/test_resources_repositories.py +4 -4
  19. gitcode_api-1.0.3/gitcode_api/_models.py +0 -272
  20. gitcode_api-1.0.3/gitcode_api/resources/collaboration.py +0 -1489
  21. gitcode_api-1.0.3/gitcode_api/resources/misc.py +0 -345
  22. gitcode_api-1.0.3/gitcode_api.egg-info/requires.txt +0 -2
  23. gitcode_api-1.0.3/tests/test_client.py +0 -35
  24. gitcode_api-1.0.3/tests/test_models.py +0 -16
  25. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/LICENSE +0 -0
  26. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/__init__.py +0 -0
  27. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/_base_client.py +0 -0
  28. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/_exceptions.py +0 -0
  29. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api/resources/__init__.py +0 -0
  30. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api.egg-info/SOURCES.txt +0 -0
  31. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api.egg-info/dependency_links.txt +0 -0
  32. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/gitcode_api.egg-info/top_level.txt +0 -0
  33. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/setup.cfg +0 -0
  34. {gitcode_api-1.0.3 → gitcode_api-1.1.1}/tests/test_base_client.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-api
3
- Version: 1.0.3
3
+ Version: 1.1.1
4
4
  Summary: Easy to use Python SDK for the GitCode REST API, community-maintained.
5
5
  Author-email: Hugo Huang <hugo@hugohuang.com>
6
6
  License-Expression: MIT
7
- Project-URL: github, https://github.com/Trenza1ore/GitCode-API
7
+ Project-URL: documentation, https://gitcode-api.readthedocs.io
8
8
  Project-URL: gitcode, https://gitcode.com/SushiNinja/GitCode-API
9
- Project-URL: documentation, https://gitcode-api.readthedocs.io/en/latest/index.html
9
+ Project-URL: github, https://github.com/Trenza1ore/GitCode-API
10
10
  Keywords: gitcode,git,devops,api,sdk,python,httpx,client
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: Programming Language :: Python
@@ -23,12 +23,11 @@ Requires-Python: <4,>=3.9
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
25
  Requires-Dist: httpx
26
- Requires-Dist: python-dotenv
27
26
  Dynamic: license-file
28
27
 
29
28
  # GitCode-API
30
29
 
31
- ![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api) ![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API) ![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API) ![PyPI - License](https://img.shields.io/pypi/l/gitcode-api)
30
+ ![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F) ![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API) ![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API) ![PyPI - License](https://img.shields.io/pypi/l/gitcode-api)
32
31
 
33
32
  ![Docs](https://img.shields.io/badge/%E6%96%87%E6%A1%A3-Docs-cyan?style=for-the-badge&logo=readthedocs&link=https%3A%2F%2Fgitcode-api.readthedocs.io%2Fen%2Flatest%2Findex.html) ![中文README](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-README-brown?style=for-the-badge&logo=googledocs&link=README.zh.md) ![English README](https://img.shields.io/badge/English-README-blue?style=for-the-badge&logo=googledocs&link=README.md)
34
33
 
@@ -50,18 +49,6 @@ Install from PyPI:
50
49
  pip install gitcode-api
51
50
  ```
52
51
 
53
- For local development from source:
54
-
55
- ```bash
56
- uv sync
57
- ```
58
-
59
- Install documentation dependencies:
60
-
61
- ```bash
62
- uv sync --group docs
63
- ```
64
-
65
52
  ## Authentication
66
53
 
67
54
  Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
@@ -113,6 +100,35 @@ async def main() -> None:
113
100
  asyncio.run(main())
114
101
  ```
115
102
 
103
+ ### Context managers
104
+
105
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. When the SDK creates the underlying httpx client for you, leaving the block calls `close()` / `await close()` on that client automatically.
106
+
107
+ ```python
108
+ from gitcode_api import GitCode
109
+
110
+ with GitCode(owner="SushiNinja", repo="GitCode-API") as client:
111
+ repo = client.repos.get()
112
+ print(repo.full_name)
113
+ ```
114
+
115
+ ```python
116
+ import asyncio
117
+
118
+ from gitcode_api import AsyncGitCode
119
+
120
+
121
+ async def main() -> None:
122
+ async with AsyncGitCode(owner="SushiNinja", repo="GitCode-API") as client:
123
+ pulls = await client.pulls.list(state="open", per_page=20)
124
+ print(len(pulls))
125
+
126
+
127
+ asyncio.run(main())
128
+ ```
129
+
130
+ If you pass a custom `http_client=`, the SDK does not close it; you still own that client’s lifecycle (for example `async with httpx.AsyncClient(...) as http:` plus `AsyncGitCode(http_client=http)`).
131
+
116
132
  ## Common Workflows
117
133
 
118
134
  Create a pull request:
@@ -1,6 +1,6 @@
1
1
  # GitCode-API
2
2
 
3
- ![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api) ![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API) ![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API) ![PyPI - License](https://img.shields.io/pypi/l/gitcode-api)
3
+ ![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F) ![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API) ![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API) ![PyPI - License](https://img.shields.io/pypi/l/gitcode-api)
4
4
 
5
5
  ![Docs](https://img.shields.io/badge/%E6%96%87%E6%A1%A3-Docs-cyan?style=for-the-badge&logo=readthedocs&link=https%3A%2F%2Fgitcode-api.readthedocs.io%2Fen%2Flatest%2Findex.html) ![中文README](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-README-brown?style=for-the-badge&logo=googledocs&link=README.zh.md) ![English README](https://img.shields.io/badge/English-README-blue?style=for-the-badge&logo=googledocs&link=README.md)
6
6
 
@@ -22,18 +22,6 @@ Install from PyPI:
22
22
  pip install gitcode-api
23
23
  ```
24
24
 
25
- For local development from source:
26
-
27
- ```bash
28
- uv sync
29
- ```
30
-
31
- Install documentation dependencies:
32
-
33
- ```bash
34
- uv sync --group docs
35
- ```
36
-
37
25
  ## Authentication
38
26
 
39
27
  Pass `api_key=` directly, or set `GITCODE_ACCESS_TOKEN` in your environment:
@@ -85,6 +73,35 @@ async def main() -> None:
85
73
  asyncio.run(main())
86
74
  ```
87
75
 
76
+ ### Context managers
77
+
78
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. When the SDK creates the underlying httpx client for you, leaving the block calls `close()` / `await close()` on that client automatically.
79
+
80
+ ```python
81
+ from gitcode_api import GitCode
82
+
83
+ with GitCode(owner="SushiNinja", repo="GitCode-API") as client:
84
+ repo = client.repos.get()
85
+ print(repo.full_name)
86
+ ```
87
+
88
+ ```python
89
+ import asyncio
90
+
91
+ from gitcode_api import AsyncGitCode
92
+
93
+
94
+ async def main() -> None:
95
+ async with AsyncGitCode(owner="SushiNinja", repo="GitCode-API") as client:
96
+ pulls = await client.pulls.list(state="open", per_page=20)
97
+ print(len(pulls))
98
+
99
+
100
+ asyncio.run(main())
101
+ ```
102
+
103
+ If you pass a custom `http_client=`, the SDK does not close it; you still own that client’s lifecycle (for example `async with httpx.AsyncClient(...) as http:` plus `AsyncGitCode(http_client=http)`).
104
+
88
105
  ## Common Workflows
89
106
 
90
107
  Create a pull request:
@@ -140,6 +140,9 @@ class GitCode(SyncAPIClient):
140
140
  self.search = SearchResource(self)
141
141
  self.oauth = OAuthResource(self)
142
142
 
143
+ def __enter__(self) -> "GitCode":
144
+ return self
145
+
143
146
 
144
147
  class AsyncGitCode(AsyncAPIClient):
145
148
  """Asynchronous GitCode API client.
@@ -235,3 +238,6 @@ class AsyncGitCode(AsyncAPIClient):
235
238
  self.orgs = AsyncOrgsResource(self)
236
239
  self.search = AsyncSearchResource(self)
237
240
  self.oauth = AsyncOAuthResource(self)
241
+
242
+ async def __aenter__(self) -> "AsyncGitCode":
243
+ return self