gitcode-api 1.2.0__tar.gz → 1.2.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 (36) hide show
  1. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/PKG-INFO +14 -23
  2. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/README.md +13 -22
  3. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/__main__.py +2 -0
  4. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_base_resource.py +1 -1
  5. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_client.py +2 -0
  6. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_models.py +7 -0
  7. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/cli.py +3 -1
  8. gitcode_api-1.2.1/gitcode_api/version.txt +1 -0
  9. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/PKG-INFO +14 -23
  10. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/pyproject.toml +5 -1
  11. gitcode_api-1.2.0/gitcode_api/version.txt +0 -1
  12. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/LICENSE +0 -0
  13. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/__init__.py +0 -0
  14. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_base_client.py +0 -0
  15. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_cli_banner.py +0 -0
  16. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/_exceptions.py +0 -0
  17. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/__init__.py +0 -0
  18. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/_shared.py +0 -0
  19. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/account.py +0 -0
  20. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/collaboration.py +0 -0
  21. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/misc.py +0 -0
  22. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api/resources/repositories.py +0 -0
  23. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/SOURCES.txt +0 -0
  24. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/dependency_links.txt +0 -0
  25. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/entry_points.txt +0 -0
  26. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/requires.txt +0 -0
  27. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/gitcode_api.egg-info/top_level.txt +0 -0
  28. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/setup.cfg +0 -0
  29. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_base_client.py +0 -0
  30. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_cli.py +0 -0
  31. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_client.py +0 -0
  32. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_models.py +0 -0
  33. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_resources_account.py +0 -0
  34. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_resources_collaboration.py +0 -0
  35. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_resources_misc.py +0 -0
  36. {gitcode_api-1.2.0 → gitcode_api-1.2.1}/tests/test_resources_repositories.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-api
3
- Version: 1.2.0
3
+ Version: 1.2.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
@@ -120,7 +120,7 @@ asyncio.run(main())
120
120
 
121
121
  ### Context managers
122
122
 
123
- `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in.
123
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
124
124
 
125
125
  ```python
126
126
  from gitcode_api import GitCode
@@ -151,16 +151,13 @@ from gitcode_api import GitCode
151
151
 
152
152
  client = GitCode(owner="SushiNinja", repo="GitCode-API")
153
153
 
154
- try:
155
- pull = client.pulls.create(
156
- title="Add feature",
157
- head="feature-branch",
158
- base="main",
159
- body="Implements the new flow.",
160
- )
161
- print(pull.number)
162
- finally:
163
- client.close()
154
+ pull = client.pulls.create(
155
+ title="Add feature",
156
+ head="feature-branch",
157
+ base="main",
158
+ body="Implements the new flow.",
159
+ )
160
+ print(pull.number)
164
161
  ```
165
162
 
166
163
  Get the authenticated user:
@@ -170,11 +167,8 @@ from gitcode_api import GitCode
170
167
 
171
168
  client = GitCode()
172
169
 
173
- try:
174
- user = client.users.me()
175
- print(user.login)
176
- finally:
177
- client.close()
170
+ user = client.users.me()
171
+ print(user.login)
178
172
  ```
179
173
 
180
174
  Search repositories:
@@ -184,12 +178,9 @@ from gitcode_api import GitCode
184
178
 
185
179
  client = GitCode()
186
180
 
187
- try:
188
- repos = client.search.repositories(q="sdk language:python", per_page=10)
189
- for repo in repos:
190
- print(repo.full_name)
191
- finally:
192
- client.close()
181
+ repos = client.search.repositories(q="sdk language:python", per_page=10)
182
+ for repo in repos:
183
+ print(repo.full_name)
193
184
  ```
194
185
 
195
186
  ## Available Resources
@@ -93,7 +93,7 @@ asyncio.run(main())
93
93
 
94
94
  ### Context managers
95
95
 
96
- `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in.
96
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
97
97
 
98
98
  ```python
99
99
  from gitcode_api import GitCode
@@ -124,16 +124,13 @@ from gitcode_api import GitCode
124
124
 
125
125
  client = GitCode(owner="SushiNinja", repo="GitCode-API")
126
126
 
127
- try:
128
- pull = client.pulls.create(
129
- title="Add feature",
130
- head="feature-branch",
131
- base="main",
132
- body="Implements the new flow.",
133
- )
134
- print(pull.number)
135
- finally:
136
- client.close()
127
+ pull = client.pulls.create(
128
+ title="Add feature",
129
+ head="feature-branch",
130
+ base="main",
131
+ body="Implements the new flow.",
132
+ )
133
+ print(pull.number)
137
134
  ```
138
135
 
139
136
  Get the authenticated user:
@@ -143,11 +140,8 @@ from gitcode_api import GitCode
143
140
 
144
141
  client = GitCode()
145
142
 
146
- try:
147
- user = client.users.me()
148
- print(user.login)
149
- finally:
150
- client.close()
143
+ user = client.users.me()
144
+ print(user.login)
151
145
  ```
152
146
 
153
147
  Search repositories:
@@ -157,12 +151,9 @@ from gitcode_api import GitCode
157
151
 
158
152
  client = GitCode()
159
153
 
160
- try:
161
- repos = client.search.repositories(q="sdk language:python", per_page=10)
162
- for repo in repos:
163
- print(repo.full_name)
164
- finally:
165
- client.close()
154
+ repos = client.search.repositories(q="sdk language:python", per_page=10)
155
+ for repo in repos:
156
+ print(repo.full_name)
166
157
  ```
167
158
 
168
159
  ## Available Resources
@@ -1,3 +1,5 @@
1
+ """Run the package CLI via ``python -m gitcode_api``."""
2
+
1
3
  from .cli import main
2
4
 
3
5
  if __name__ == "__main__":
@@ -7,7 +7,7 @@ _DATA_MODEL_PATH = "gitcode_api._models."
7
7
 
8
8
 
9
9
  class BaseResource:
10
- """Resource group base class"""
10
+ """Resource group base class."""
11
11
 
12
12
  def __del__(self) -> None:
13
13
  """Attempt to clear the lru cache."""
@@ -144,6 +144,7 @@ class GitCode(SyncAPIClient):
144
144
  self.oauth = OAuthResource(self)
145
145
 
146
146
  def __enter__(self) -> "GitCode":
147
+ """Enter synchronous context and return this client."""
147
148
  return self
148
149
 
149
150
 
@@ -246,4 +247,5 @@ class AsyncGitCode(AsyncAPIClient):
246
247
  self.oauth = AsyncOAuthResource(self)
247
248
 
248
249
  async def __aenter__(self) -> "AsyncGitCode":
250
+ """Enter asynchronous context and return this client."""
249
251
  return self
@@ -73,6 +73,7 @@ class APIObject(Mapping[str, Any]):
73
73
  data: MutableMapping[str, Any] = field(init=False, repr=False)
74
74
 
75
75
  def __init__(self, data: Mapping[str, Any]):
76
+ """Initialize from API response data."""
76
77
  payload = dict(data)
77
78
  object.__setattr__(self, "data", payload)
78
79
  type_hints = get_type_hints(self.__class__)
@@ -95,24 +96,30 @@ class APIObject(Mapping[str, Any]):
95
96
  object.__setattr__(self, model_field.name, value)
96
97
 
97
98
  def __getitem__(self, key: str) -> Any:
99
+ """Return the value for ``key`` from the backing mapping."""
98
100
  return _wrap_value(self.data[key])
99
101
 
100
102
  def __iter__(self) -> Iterator[str]:
103
+ """Iterate keys of the backing mapping."""
101
104
  return iter(self.data)
102
105
 
103
106
  def __len__(self) -> int:
107
+ """Return the number of keys in the backing mapping."""
104
108
  return len(self.data)
105
109
 
106
110
  def __getattr__(self, name: str) -> Any:
111
+ """Resolve unknown attributes from the backing mapping."""
107
112
  try:
108
113
  return _wrap_value(self.data[name])
109
114
  except KeyError as exc:
110
115
  raise AttributeError(name) from exc
111
116
 
112
117
  def get(self, key: str, default: Any = None) -> Any:
118
+ """Return the value for ``key``, or ``default`` if missing."""
113
119
  return _wrap_value(self.data.get(key, default))
114
120
 
115
121
  def to_dict(self) -> Dict[str, Any]:
122
+ """Return a shallow copy of the backing mapping."""
116
123
  return dict(self.data)
117
124
 
118
125
 
@@ -174,7 +174,7 @@ def _write_output(value: Any, *, output_file: Optional[str], compact: bool) -> N
174
174
 
175
175
 
176
176
  def _invocation_parent_parser() -> argparse.ArgumentParser:
177
- """Flags for real API calls (attached only to leaf METHOD parsers, not top-level usage)."""
177
+ """Parser with flags for real API calls (attached only to leaf METHOD parsers, not top-level usage)."""
178
178
  parser = argparse.ArgumentParser(add_help=False)
179
179
  parser.add_argument("--api-key", help=f"GitCode access token. Defaults to {DEFAULT_TOKEN_ENV}.")
180
180
  parser.add_argument("--owner", help="Default repository owner.")
@@ -191,6 +191,7 @@ def _root_banner() -> str:
191
191
 
192
192
 
193
193
  def build_parser() -> argparse.ArgumentParser:
194
+ """Build main parser."""
194
195
  common = _invocation_parent_parser()
195
196
  epilog = """\
196
197
  Examples:
@@ -334,6 +335,7 @@ def _collect_kwargs(args: argparse.Namespace, method: Any) -> dict[str, Any]:
334
335
 
335
336
 
336
337
  def main(argv: Optional[Sequence[str]] = None) -> int:
338
+ """CLI entry point."""
337
339
  parser = build_parser()
338
340
  effective = list(sys.argv[1:] if argv is None else argv)
339
341
  if not effective:
@@ -0,0 +1 @@
1
+ 1.2.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-api
3
- Version: 1.2.0
3
+ Version: 1.2.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
@@ -120,7 +120,7 @@ asyncio.run(main())
120
120
 
121
121
  ### Context managers
122
122
 
123
- `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in.
123
+ `GitCode` and `AsyncGitCode` (and the lower-level `SyncAPIClient` / `AsyncAPIClient`) support `with` / `async with`. Leaving the block calls `close()` / `await close()` on the underlying client automatically, including a custom `http_client=` you passed in. `close()` also clears the LRU cache used by each resource group's `method_signature(...)` helper (see the [Available Resources](#available-resources) section).
124
124
 
125
125
  ```python
126
126
  from gitcode_api import GitCode
@@ -151,16 +151,13 @@ from gitcode_api import GitCode
151
151
 
152
152
  client = GitCode(owner="SushiNinja", repo="GitCode-API")
153
153
 
154
- try:
155
- pull = client.pulls.create(
156
- title="Add feature",
157
- head="feature-branch",
158
- base="main",
159
- body="Implements the new flow.",
160
- )
161
- print(pull.number)
162
- finally:
163
- client.close()
154
+ pull = client.pulls.create(
155
+ title="Add feature",
156
+ head="feature-branch",
157
+ base="main",
158
+ body="Implements the new flow.",
159
+ )
160
+ print(pull.number)
164
161
  ```
165
162
 
166
163
  Get the authenticated user:
@@ -170,11 +167,8 @@ from gitcode_api import GitCode
170
167
 
171
168
  client = GitCode()
172
169
 
173
- try:
174
- user = client.users.me()
175
- print(user.login)
176
- finally:
177
- client.close()
170
+ user = client.users.me()
171
+ print(user.login)
178
172
  ```
179
173
 
180
174
  Search repositories:
@@ -184,12 +178,9 @@ from gitcode_api import GitCode
184
178
 
185
179
  client = GitCode()
186
180
 
187
- try:
188
- repos = client.search.repositories(q="sdk language:python", per_page=10)
189
- for repo in repos:
190
- print(repo.full_name)
191
- finally:
192
- client.close()
181
+ repos = client.search.repositories(q="sdk language:python", per_page=10)
182
+ for repo in repos:
183
+ print(repo.full_name)
193
184
  ```
194
185
 
195
186
  ## Available Resources
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gitcode-api"
3
- version = "1.2.0"
3
+ version = "1.2.1"
4
4
  description = "Easy to use Python SDK for the GitCode REST API, community-maintained."
5
5
  keywords = ["gitcode", "git", "devops", "api", "sdk", "python", "httpx", "client"]
6
6
  readme = "README.md"
@@ -37,6 +37,7 @@ docs = [
37
37
  "sphinx",
38
38
  "sphinx-rtd-theme",
39
39
  "beautifulsoup4",
40
+ "myst-parser>=3.0.1,<4",
40
41
  ]
41
42
 
42
43
  # Formatting
@@ -73,6 +74,9 @@ addopts = ["-v"]
73
74
  line-length = 120
74
75
  target-version = "py39"
75
76
 
77
+ [tool.ruff.pydocstyle]
78
+ convention = "pep257"
79
+
76
80
  [tool.pylint.MAIN]
77
81
  ignore-paths = ["^(examples|tests|docs|scripts)/.*"]
78
82
  py-version = "3.9"
@@ -1 +0,0 @@
1
- 1.2.0
File without changes
File without changes