python-gitea 0.2.0__tar.gz → 0.3.0__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 (110) hide show
  1. {python_gitea-0.2.0 → python_gitea-0.3.0}/.pre-commit-config.yaml +4 -4
  2. {python_gitea-0.2.0 → python_gitea-0.3.0}/PKG-INFO +3 -3
  3. {python_gitea-0.2.0 → python_gitea-0.3.0}/mkdocs.yml +6 -2
  4. {python_gitea-0.2.0 → python_gitea-0.3.0}/pyproject.toml +4 -2
  5. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/__init__.py +1 -3
  6. python_gitea-0.3.0/src/gitea/cli/__init__.py +1 -0
  7. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/main.py +5 -1
  8. python_gitea-0.3.0/src/gitea/cli/user/__init__.py +1 -0
  9. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/delete_user_level_runner.py +4 -2
  10. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/get_registration_token.py +2 -2
  11. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/get_user.py +4 -1
  12. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/get_user_level_runners.py +2 -2
  13. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/get_workflow_jobs.py +4 -1
  14. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/get_workflow_runs.py +4 -1
  15. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/utils.py +1 -0
  16. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/client/async_gitea.py +6 -0
  17. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/client/base.py +3 -0
  18. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/client/gitea.py +5 -0
  19. python_gitea-0.3.0/src/gitea/issue/__init__.py +8 -0
  20. python_gitea-0.3.0/src/gitea/issue/async_issue.py +277 -0
  21. python_gitea-0.3.0/src/gitea/issue/base.py +201 -0
  22. python_gitea-0.3.0/src/gitea/issue/issue.py +277 -0
  23. python_gitea-0.3.0/src/gitea/resource/__init__.py +1 -0
  24. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/resource/async_resource.py +11 -5
  25. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/resource/resource.py +11 -5
  26. python_gitea-0.3.0/src/gitea/user/__init__.py +1 -0
  27. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/user/async_user.py +4 -0
  28. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/user/base.py +4 -0
  29. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/user/user.py +3 -0
  30. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/utils/log.py +3 -2
  31. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/utils/response.py +2 -0
  32. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/version.py +1 -3
  33. python_gitea-0.3.0/tests/__init__.py +1 -0
  34. python_gitea-0.3.0/tests/cli/__init__.py +1 -0
  35. python_gitea-0.3.0/tests/cli/user/__init__.py +1 -0
  36. python_gitea-0.3.0/tests/client/__init__.py +1 -0
  37. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/conftest.py +3 -4
  38. python_gitea-0.3.0/tests/issue/__init__.py +1 -0
  39. python_gitea-0.3.0/tests/issue/test_issue_async_issue.py +65 -0
  40. python_gitea-0.3.0/tests/issue/test_issue_base.py +117 -0
  41. python_gitea-0.3.0/tests/issue/test_issue_issue.py +62 -0
  42. python_gitea-0.3.0/tests/resource/__init__.py +1 -0
  43. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/test_import.py +1 -0
  44. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/test_version.py +0 -1
  45. python_gitea-0.3.0/tests/user/__init__.py +1 -0
  46. python_gitea-0.3.0/tests/utils/__init__.py +1 -0
  47. python_gitea-0.2.0/src/gitea/cli/__init__.py +0 -0
  48. python_gitea-0.2.0/src/gitea/cli/user/__init__.py +0 -0
  49. python_gitea-0.2.0/src/gitea/resource/__init__.py +0 -0
  50. python_gitea-0.2.0/src/gitea/user/__init__.py +0 -0
  51. python_gitea-0.2.0/tests/__init__.py +0 -0
  52. python_gitea-0.2.0/tests/cli/__init__.py +0 -0
  53. python_gitea-0.2.0/tests/cli/user/__init__.py +0 -0
  54. python_gitea-0.2.0/tests/client/__init__.py +0 -0
  55. python_gitea-0.2.0/tests/resource/__init__.py +0 -0
  56. python_gitea-0.2.0/tests/user/__init__.py +0 -0
  57. python_gitea-0.2.0/tests/utils/__init__.py +0 -0
  58. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/dependabot.yml +0 -0
  59. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/CI.yml +0 -0
  60. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/create_tag.yml +0 -0
  61. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/documentation.yml +0 -0
  62. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/draft_release.yml +0 -0
  63. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/publish.yml +0 -0
  64. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/publish_testpypi.yml +0 -0
  65. {python_gitea-0.2.0 → python_gitea-0.3.0}/.github/workflows/release.yml +0 -0
  66. {python_gitea-0.2.0 → python_gitea-0.3.0}/.gitignore +0 -0
  67. {python_gitea-0.2.0 → python_gitea-0.3.0}/.ignore_words.txt +0 -0
  68. {python_gitea-0.2.0 → python_gitea-0.3.0}/.markdownlint.yaml +0 -0
  69. {python_gitea-0.2.0 → python_gitea-0.3.0}/.pypirc +0 -0
  70. {python_gitea-0.2.0 → python_gitea-0.3.0}/CITATION.cff +0 -0
  71. {python_gitea-0.2.0 → python_gitea-0.3.0}/CODE_OF_CONDUCT.md +0 -0
  72. {python_gitea-0.2.0 → python_gitea-0.3.0}/CONTRIBUTING.md +0 -0
  73. {python_gitea-0.2.0 → python_gitea-0.3.0}/LICENSE +0 -0
  74. {python_gitea-0.2.0 → python_gitea-0.3.0}/README.md +0 -0
  75. {python_gitea-0.2.0 → python_gitea-0.3.0}/SECURITY.md +0 -0
  76. {python_gitea-0.2.0 → python_gitea-0.3.0}/SUPPORT.md +0 -0
  77. {python_gitea-0.2.0 → python_gitea-0.3.0}/cliff.toml +0 -0
  78. {python_gitea-0.2.0 → python_gitea-0.3.0}/commitlint.config.js +0 -0
  79. {python_gitea-0.2.0 → python_gitea-0.3.0}/cspell.json +0 -0
  80. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/dev/troubleshooting.md +0 -0
  81. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/gen_ref_pages.py +0 -0
  82. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/index.md +0 -0
  83. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/javascripts/mathjax.js +0 -0
  84. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/style/api.css +0 -0
  85. {python_gitea-0.2.0 → python_gitea-0.3.0}/docs/user_guide/installation.md +0 -0
  86. {python_gitea-0.2.0 → python_gitea-0.3.0}/package.json +0 -0
  87. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/__main__.py +0 -0
  88. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/cli/user/main.py +0 -0
  89. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/client/__init__.py +0 -0
  90. {python_gitea-0.2.0 → python_gitea-0.3.0}/src/gitea/utils/__init__.py +0 -0
  91. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/test_cli_main.py +0 -0
  92. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/test_cli_utils.py +0 -0
  93. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_delete_user_level_runner.py +0 -0
  94. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_get_registration_token.py +0 -0
  95. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_get_user.py +0 -0
  96. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_get_user_level_runners.py +0 -0
  97. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_get_workflow_jobs.py +0 -0
  98. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_get_workflow_runs.py +0 -0
  99. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/cli/user/test_cli_user_main.py +0 -0
  100. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/client/test_client_async_gitea.py +0 -0
  101. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/client/test_client_base.py +0 -0
  102. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/client/test_client_gitea.py +0 -0
  103. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/resource/test_resource_async_resource.py +0 -0
  104. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/resource/test_resource_resource.py +0 -0
  105. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/test_main.py +0 -0
  106. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/user/test_user_async_user.py +0 -0
  107. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/user/test_user_base.py +0 -0
  108. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/user/test_user_user.py +0 -0
  109. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/utils/test_utils_log.py +0 -0
  110. {python_gitea-0.2.0 → python_gitea-0.3.0}/tests/utils/test_utils_response.py +0 -0
@@ -13,7 +13,7 @@ ci:
13
13
 
14
14
  repos:
15
15
  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
16
- rev: v9.23.0
16
+ rev: v9.24.0
17
17
  hooks:
18
18
  - id: commitlint
19
19
  stages: [commit-msg]
@@ -50,14 +50,14 @@ repos:
50
50
  stages: [pre-commit]
51
51
 
52
52
  - repo: https://github.com/astral-sh/ruff-pre-commit
53
- rev: v0.14.11
53
+ rev: v0.14.13
54
54
  hooks:
55
55
  - id: ruff
56
56
  args: [--fix, --config=pyproject.toml]
57
57
  stages: [pre-commit]
58
58
 
59
59
  - repo: https://github.com/psf/black-pre-commit-mirror
60
- rev: 25.12.0 # Matches pyproject.toml
60
+ rev: 26.1.0 # Matches pyproject.toml
61
61
  hooks:
62
62
  - id: black
63
63
  args: [--config=pyproject.toml]
@@ -118,7 +118,7 @@ repos:
118
118
  stages: [pre-commit]
119
119
 
120
120
  - repo: https://github.com/PyCQA/bandit
121
- rev: "1.9.2"
121
+ rev: "1.9.3"
122
122
  hooks:
123
123
  - id: bandit
124
124
  args: ["-c", "pyproject.toml"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-gitea
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: A Python package for interacting with the Gitea API, offering a simple interface to access repositories, users, organizations, issues, and more for automation and data management.
5
5
  Project-URL: Documentation, https://isaac-cf-wong.github.io/python-gitea
6
6
  Project-URL: Source, https://github.com/isaac-cf-wong/python-gitea
@@ -34,8 +34,8 @@ Requires-Dist: mkdocs-material; extra == 'docs'
34
34
  Requires-Dist: mkdocs-section-index; extra == 'docs'
35
35
  Requires-Dist: mkdocstrings[python]; extra == 'docs'
36
36
  Provides-Extra: test
37
- Requires-Dist: bandit[toml]==1.9.2; extra == 'test'
38
- Requires-Dist: black==25.12.0; extra == 'test'
37
+ Requires-Dist: bandit[toml]==1.9.3; extra == 'test'
38
+ Requires-Dist: black==26.1.0; extra == 'test'
39
39
  Requires-Dist: check-manifest==0.51; extra == 'test'
40
40
  Requires-Dist: flake8; extra == 'test'
41
41
  Requires-Dist: flake8-bugbear==25.11.29; extra == 'test'
@@ -76,12 +76,16 @@ nav:
76
76
  - Client:
77
77
  - Overview: reference/gitea/client/index.md
78
78
  - Base: reference/gitea/client/base.md
79
- - AsyncGitea: reference/gitea/client/async_gitea.md
79
+ - Async Gitea: reference/gitea/client/async_gitea.md
80
80
  - Gitea: reference/gitea/client/gitea.md
81
81
  - Resource:
82
82
  - Overview: reference/gitea/resource/index.md
83
83
  - Resource: reference/gitea/resource/resource.md
84
- - AsyncResource: reference/gitea/resource/async_resource.md
84
+ - Async Resource: reference/gitea/resource/async_resource.md
85
+ - Issue:
86
+ - Overview: reference/gitea/issue/index.md
87
+ - Issue: reference/gitea/issue/issue.md
88
+ - Async Issue: reference/gitea/issue/async_issue.md
85
89
  - User:
86
90
  - Overview: reference/gitea/user/index.md
87
91
  - User: reference/gitea/user/user.md
@@ -26,8 +26,8 @@ dependencies = [
26
26
 
27
27
  [project.optional-dependencies]
28
28
  test = [
29
- "bandit[toml]==1.9.2",
30
- "black==25.12.0",
29
+ "bandit[toml]==1.9.3",
30
+ "black==26.1.0",
31
31
  "check-manifest==0.51",
32
32
  "flake8-bugbear==25.11.29",
33
33
  "flake8-docstrings",
@@ -179,6 +179,8 @@ lint.extend-select = [
179
179
  "PL", # Add pylint rules for fuller coverage
180
180
  "SIM", # Similarities
181
181
  "T10", # Debugger statements
182
+ "DOC", # Docstring
183
+ "D", # Doc style
182
184
  ]
183
185
  lint.ignore = [
184
186
  "E501", # Line length (handled by formatter)
@@ -1,6 +1,4 @@
1
- """
2
- Top-level package for python-gitea.
3
- """
1
+ """Top-level package for python-gitea."""
4
2
 
5
3
  from __future__ import annotations
6
4
 
@@ -0,0 +1 @@
1
+ """Command line interface for Gitea."""
@@ -33,6 +33,7 @@ def setup_logging(level: LoggingLevel = LoggingLevel.INFO) -> None:
33
33
 
34
34
  Args:
35
35
  level: Logging level.
36
+
36
37
  """
37
38
  import logging # noqa: PLC0415
38
39
 
@@ -97,13 +98,16 @@ def main( # noqa: PLR0913
97
98
  typer.Option("--verbose", "-v", help="Set verbosity level."),
98
99
  ] = LoggingLevel.INFO,
99
100
  ) -> None:
100
- """Main entry point for the CLI application.
101
+ """Enter the CLI application.
101
102
 
102
103
  Args:
103
104
  ctx: Typer context.
105
+ output: Output file name.
104
106
  token: Gitea API token.
105
107
  base_url: Base URL of the Gitea instance.
108
+ timeout: Timeout for API requests in seconds.
106
109
  verbose: Verbosity level for logging.
110
+
107
111
  """
108
112
  setup_logging(verbose)
109
113
  ctx.obj = {
@@ -0,0 +1 @@
1
+ """User module for CLI commands."""
@@ -14,7 +14,9 @@ def delete_user_level_runner_command(
14
14
  """Delete a user-level runner for the authenticated user.
15
15
 
16
16
  Args:
17
+ ctx: The Typer context.
17
18
  runner_id: The ID of the runner to delete.
19
+
18
20
  """
19
21
  from typing import Any # noqa: PLC0415
20
22
 
@@ -26,11 +28,11 @@ def delete_user_level_runner_command(
26
28
  timeout: int = ctx.obj.get("timeout")
27
29
 
28
30
  def api_call() -> dict[str, Any] | None:
29
- """
30
- API call to delete a user-level runner.
31
+ """Delete a user-level runner.
31
32
 
32
33
  Returns:
33
34
  A dictionary containing the result of the deletion.
35
+
34
36
  """
35
37
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
36
38
  return client.user.delete_user_level_runner(runner_id=runner_id, timeout=timeout)
@@ -19,11 +19,11 @@ def get_registration_token_command(
19
19
  timeout: int = ctx.obj.get("timeout")
20
20
 
21
21
  def api_call() -> dict[str, Any] | None:
22
- """
23
- API call to get the registration token.
22
+ """Get registration token.
24
23
 
25
24
  Returns:
26
25
  A dictionary containing the registration token.
26
+
27
27
  """
28
28
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
29
29
  return client.user.get_registration_token(timeout=timeout)
@@ -16,7 +16,9 @@ def get_user_command(
16
16
  """Get user information.
17
17
 
18
18
  Args:
19
+ ctx: The Typer context.
19
20
  username: The username of the user to retrieve. If None, retrieves the authenticated user.
21
+
20
22
  """
21
23
  from typing import Any # noqa: PLC0415
22
24
 
@@ -28,10 +30,11 @@ def get_user_command(
28
30
  timeout: int = ctx.obj.get("timeout")
29
31
 
30
32
  def api_call() -> dict[str, Any] | None:
31
- """API call to get user information.
33
+ """Get user information.
32
34
 
33
35
  Returns:
34
36
  The user information as a dictionary.
37
+
35
38
  """
36
39
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
37
40
  return client.user.get_user(username=username, timeout=timeout)
@@ -22,11 +22,11 @@ def get_user_level_runners_command(
22
22
  timeout: int = ctx.obj.get("timeout")
23
23
 
24
24
  def api_call() -> dict[str, Any] | None:
25
- """
26
- API call to get user-level runners.
25
+ """Get user-level runners.
27
26
 
28
27
  Returns:
29
28
  A dictionary containing the user-level runners.
29
+
30
30
  """
31
31
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
32
32
  return client.user.get_user_level_runners(runner_id=runner_id, timeout=timeout)
@@ -22,9 +22,11 @@ def get_workflow_jobs_command(
22
22
  """Get workflow jobs for the authenticated user filtered by status.
23
23
 
24
24
  Args:
25
+ ctx: The Typer context.
25
26
  status: The status to filter workflow jobs by. Options: pending, queued, in_progress, failure, success, skipped.
26
27
  page: The page number for pagination.
27
28
  limit: The number of items per page for pagination.
29
+
28
30
  """
29
31
  from typing import Any # noqa: PLC0415
30
32
 
@@ -36,10 +38,11 @@ def get_workflow_jobs_command(
36
38
  timeout: int = ctx.obj.get("timeout")
37
39
 
38
40
  def api_call() -> dict[str, Any] | None:
39
- """API call to get workflow jobs.
41
+ """Get workflow jobs.
40
42
 
41
43
  Returns:
42
44
  A dictionary containing the workflow jobs with the specified status.
45
+
43
46
  """
44
47
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
45
48
  return client.user.get_workflow_jobs(status=status, page=page, limit=limit, timeout=timeout)
@@ -26,6 +26,7 @@ def get_workflow_runs_command( # noqa: PLR0913
26
26
  """Get workflow runs for the authenticated user filtered by various parameters.
27
27
 
28
28
  Args:
29
+ ctx: The Typer context.
29
30
  event: The event that triggered the workflow run.
30
31
  branch: The branch name to filter workflow runs.
31
32
  status: The status to filter workflow jobs by. Options: pending, queued, in_progress, failure, success, skipped.
@@ -33,6 +34,7 @@ def get_workflow_runs_command( # noqa: PLR0913
33
34
  head_sha: The head SHA to filter workflow runs.
34
35
  page: The page number for pagination.
35
36
  limit: The number of items per page for pagination.
37
+
36
38
  """
37
39
  from typing import Any # noqa: PLC0415
38
40
 
@@ -44,10 +46,11 @@ def get_workflow_runs_command( # noqa: PLR0913
44
46
  timeout: int = ctx.obj.get("timeout")
45
47
 
46
48
  def api_call() -> dict[str, Any] | None:
47
- """API call to get workflow runs.
49
+ """Get workflow runs.
48
50
 
49
51
  Returns:
50
52
  A dictionary containing the workflow runs.
53
+
51
54
  """
52
55
  with gitea.client.gitea.Gitea(token=token, base_url=base_url) as client:
53
56
  return client.user.get_workflow_runs(
@@ -22,6 +22,7 @@ def execute_api_command(
22
22
  ctx: Typer context containing token, base_url, and output.
23
23
  api_call: Callable that executes the API call and returns the result.
24
24
  command_name: Name of the command for error messages.
25
+
25
26
  """
26
27
  output: Path | None = ctx.obj.get("output")
27
28
  console = Console()
@@ -18,6 +18,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
18
18
  Args:
19
19
  token: The API token for authentication.
20
20
  base_url: The base URL of the Gitea instance.
21
+
21
22
  """
22
23
  super().__init__(token=token, base_url=base_url)
23
24
  self.session: ClientSession | None = None
@@ -27,6 +28,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
27
28
 
28
29
  Returns:
29
30
  A string representing the AsyncGitea client.
31
+
30
32
  """
31
33
  return f"AsyncGitea Client(base_url={self.base_url})"
32
34
 
@@ -35,6 +37,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
35
37
 
36
38
  Returns:
37
39
  The AsyncGitea client instance.
40
+
38
41
  """
39
42
  if self.session is not None and not self.session.closed:
40
43
  raise RuntimeError("AsyncGitea session already open; do not re-enter context manager.")
@@ -48,6 +51,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
48
51
  exc_type: The exception type.
49
52
  exc_val: The exception value.
50
53
  exc_tb: The traceback.
54
+
51
55
  """
52
56
  if self.session:
53
57
  await self.session.close()
@@ -62,6 +66,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
62
66
 
63
67
  Returns:
64
68
  The aiohttp ClientSession instance.
69
+
65
70
  """
66
71
  return ClientSession(headers=headers, **kwargs)
67
72
 
@@ -79,6 +84,7 @@ class AsyncGitea(Client): # pylint: disable=too-few-public-methods
79
84
 
80
85
  Returns:
81
86
  The aiohttp ClientResponse object.
87
+
82
88
  """
83
89
  if self.session is None:
84
90
  raise RuntimeError(
@@ -14,6 +14,7 @@ class Client: # pylint: disable=too-few-public-methods
14
14
  Args:
15
15
  token: The API token for authentication.
16
16
  base_url: The base URL of the Gitea instance.
17
+
17
18
  """
18
19
  self.token = token
19
20
  self.base_url = base_url.rstrip("/")
@@ -27,6 +28,7 @@ class Client: # pylint: disable=too-few-public-methods
27
28
 
28
29
  Returns:
29
30
  str: The base API URL.
31
+
30
32
  """
31
33
  return f"{self.base_url}/api/v1"
32
34
 
@@ -38,5 +40,6 @@ class Client: # pylint: disable=too-few-public-methods
38
40
 
39
41
  Returns:
40
42
  str: The full URL.
43
+
41
44
  """
42
45
  return f"{self.api_url}/{endpoint.lstrip('/')}"
@@ -20,6 +20,7 @@ class Gitea(Client): # pylint: disable=too-few-public-methods
20
20
  Args:
21
21
  token: The API token for authentication.
22
22
  base_url: The base URL of the Gitea instance.
23
+
23
24
  """
24
25
  super().__init__(token=token, base_url=base_url)
25
26
  self.session: requests.Session | None = None
@@ -30,6 +31,7 @@ class Gitea(Client): # pylint: disable=too-few-public-methods
30
31
 
31
32
  Returns:
32
33
  A string representing the Gitea client.
34
+
33
35
  """
34
36
  return f"Gitea Client(base_url={self.base_url})"
35
37
 
@@ -38,6 +40,7 @@ class Gitea(Client): # pylint: disable=too-few-public-methods
38
40
 
39
41
  Returns:
40
42
  The Gitea client instance.
43
+
41
44
  """
42
45
  if self.session is not None:
43
46
  raise RuntimeError("Gitea session already open; do not re-enter context manager.")
@@ -51,6 +54,7 @@ class Gitea(Client): # pylint: disable=too-few-public-methods
51
54
  exc_type: The exception type.
52
55
  exc_val: The exception value.
53
56
  exc_tb: The traceback.
57
+
54
58
  """
55
59
  if self.session:
56
60
  self.session.close()
@@ -70,6 +74,7 @@ class Gitea(Client): # pylint: disable=too-few-public-methods
70
74
 
71
75
  Returns:
72
76
  The HTTP response object.
77
+
73
78
  """
74
79
  if self.session is None:
75
80
  raise RuntimeError(
@@ -0,0 +1,8 @@
1
+ """Gitea Issue resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from gitea.issue.async_issue import AsyncIssue
6
+ from gitea.issue.issue import Issue
7
+
8
+ __all__ = ["AsyncIssue", "Issue"]
@@ -0,0 +1,277 @@
1
+ """Asynchronous Gitea Issue resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from datetime import datetime
6
+ from typing import Any, Literal, cast
7
+
8
+ from aiohttp import ClientResponse
9
+
10
+ from gitea.issue.base import BaseIssue
11
+ from gitea.resource.async_resource import AsyncResource
12
+ from gitea.utils.response import process_async_response
13
+
14
+
15
+ class AsyncIssue(BaseIssue, AsyncResource):
16
+ """Asynchronous Gitea Issue resource."""
17
+
18
+ async def _list_issues( # noqa: PLR0913
19
+ self,
20
+ owner: str,
21
+ repository: str,
22
+ state: Literal["closed", "open", "all"] | None = None,
23
+ labels: list[str] | None = None,
24
+ search_string: str | None = None,
25
+ issue_type: Literal["issues", "pulls"] | None = None,
26
+ milestones: list[str] | list[int] | None = None,
27
+ since: datetime | None = None,
28
+ before: datetime | None = None,
29
+ created_by: str | None = None,
30
+ assigned_by: str | None = None,
31
+ mentioned_by: str | None = None,
32
+ page: int | None = None,
33
+ limit: int | None = None,
34
+ **kwargs: Any,
35
+ ) -> ClientResponse:
36
+ """List issues in a repository.
37
+
38
+ Args:
39
+ owner: The owner of the repository.
40
+ repository: The name of the repository.
41
+ state: Filter issues by state.
42
+ labels: Filter issues by labels.
43
+ search_string: Filter issues by search string.
44
+ issue_type: Filter by issue type.
45
+ milestones: Filter issues by milestones.
46
+ since: Filter issues updated since this time.
47
+ before: Filter issues updated before this time.
48
+ created_by: Filter issues created by this user.
49
+ assigned_by: Filter issues assigned to this user.
50
+ mentioned_by: Filter issues mentioning this user.
51
+ page: The page number for pagination.
52
+ limit: The number of issues per page.
53
+ **kwargs: Additional arguments for the request.
54
+
55
+ Returns:
56
+ The HTTP response object.
57
+
58
+ """
59
+ endpoint, params = self._list_issues_helper(
60
+ owner=owner,
61
+ repository=repository,
62
+ state=state,
63
+ labels=labels,
64
+ search_string=search_string,
65
+ issue_type=issue_type,
66
+ milestones=milestones,
67
+ since=since,
68
+ before=before,
69
+ created_by=created_by,
70
+ assigned_by=assigned_by,
71
+ mentioned_by=mentioned_by,
72
+ page=page,
73
+ limit=limit,
74
+ )
75
+ return await self._get(endpoint=endpoint, params=params, **kwargs)
76
+
77
+ async def list_issues( # noqa: PLR0913
78
+ self,
79
+ owner: str,
80
+ repository: str,
81
+ state: Literal["closed", "open", "all"] | None = None,
82
+ labels: list[str] | None = None,
83
+ search_string: str | None = None,
84
+ issue_type: Literal["issues", "pulls"] | None = None,
85
+ milestones: list[str] | list[int] | None = None,
86
+ since: datetime | None = None,
87
+ before: datetime | None = None,
88
+ created_by: str | None = None,
89
+ assigned_by: str | None = None,
90
+ mentioned_by: str | None = None,
91
+ page: int | None = None,
92
+ limit: int | None = None,
93
+ **kwargs: Any,
94
+ ) -> tuple[list[dict[str, Any]], int]:
95
+ """List issues in a repository.
96
+
97
+ Args:
98
+ owner: The owner of the repository.
99
+ repository: The name of the repository.
100
+ state: Filter issues by state.
101
+ labels: Filter issues by labels.
102
+ search_string: Filter issues by search string.
103
+ issue_type: Filter by issue type.
104
+ milestones: Filter issues by milestones.
105
+ since: Filter issues updated since this time.
106
+ before: Filter issues updated before this time.
107
+ created_by: Filter issues created by this user.
108
+ assigned_by: Filter issues assigned to this user.
109
+ mentioned_by: Filter issues mentioning this user.
110
+ page: The page number for pagination.
111
+ limit: The number of issues per page.
112
+ **kwargs: Additional arguments for the request.
113
+
114
+ Returns:
115
+ A tuple containing the list of issues as a list of dictionaries and the status code.
116
+
117
+ """
118
+ response = await self._list_issues(
119
+ owner=owner,
120
+ repository=repository,
121
+ state=state,
122
+ labels=labels,
123
+ search_string=search_string,
124
+ issue_type=issue_type,
125
+ milestones=milestones,
126
+ since=since,
127
+ before=before,
128
+ created_by=created_by,
129
+ assigned_by=assigned_by,
130
+ mentioned_by=mentioned_by,
131
+ page=page,
132
+ limit=limit,
133
+ **kwargs,
134
+ )
135
+ data, status_code = await process_async_response(response)
136
+ return cast(list[dict[str, Any]], data), status_code
137
+
138
+ async def _get_issue(self, owner: str, repository: str, index: int, **kwargs: Any) -> ClientResponse:
139
+ """Get a single issue by its index.
140
+
141
+ Args:
142
+ owner: The owner of the repository.
143
+ repository: The name of the repository.
144
+ index: The index of the issue.
145
+ **kwargs: Additional arguments for the request.
146
+
147
+ Returns:
148
+ The HTTP response object.
149
+
150
+ """
151
+ endpoint = self._get_issue_helper(owner=owner, repository=repository, index=index)
152
+ return await self._get(endpoint=endpoint, **kwargs)
153
+
154
+ async def get_issue(self, owner: str, repository: str, index: int, **kwargs: Any) -> tuple[dict[str, Any], int]:
155
+ """Get a single issue by its index.
156
+
157
+ Args:
158
+ owner: The owner of the repository.
159
+ repository: The name of the repository.
160
+ index: The index of the issue.
161
+ **kwargs: Additional arguments for the request.
162
+
163
+ Returns:
164
+ A tuple containing the issue as a dictionary and the status code.
165
+
166
+ """
167
+ response = await self._get_issue(owner=owner, repository=repository, index=index, **kwargs)
168
+ data, status_code = await process_async_response(response)
169
+ return cast(dict[str, Any], data), status_code
170
+
171
+ async def _edit_issue( # noqa: PLR0913
172
+ self,
173
+ owner: str,
174
+ repository: str,
175
+ index: int,
176
+ assignee: str | None = None,
177
+ assignees: list[str] | None = None,
178
+ body: str | None = None,
179
+ due_date: datetime | None = None,
180
+ milestone: int | None = None,
181
+ ref: str | None = None,
182
+ state: Literal["closed", "open"] | None = None,
183
+ title: str | None = None,
184
+ unset_due_date: bool | None = None,
185
+ **kwargs: Any,
186
+ ) -> ClientResponse:
187
+ """Edit a specific issue in a repository.
188
+
189
+ Args:
190
+ owner: The owner of the repository.
191
+ repository: The name of the repository.
192
+ index: The index of the issue.
193
+ assignee: The new assignee of the issue.
194
+ assignees: The new assignees of the issue.
195
+ body: The new body of the issue.
196
+ due_date: The new due date of the issue.
197
+ milestone: The new milestone of the issue.
198
+ ref: The new reference of the issue.
199
+ state: The new state of the issue.
200
+ title: The new title of the issue.
201
+ unset_due_date: Whether to unset the due date of the issue.
202
+ **kwargs: Additional arguments for the request.
203
+
204
+ Returns:
205
+ The HTTP response object.
206
+
207
+ """
208
+ endpoint, payload = self._edit_issue_helper(
209
+ owner=owner,
210
+ repository=repository,
211
+ index=index,
212
+ assignee=assignee,
213
+ assignees=assignees,
214
+ body=body,
215
+ due_date=due_date,
216
+ milestone=milestone,
217
+ ref=ref,
218
+ state=state,
219
+ title=title,
220
+ unset_due_date=unset_due_date,
221
+ )
222
+ return await self._patch(endpoint=endpoint, json=payload, **kwargs)
223
+
224
+ async def edit_issue( # noqa: PLR0913
225
+ self,
226
+ owner: str,
227
+ repository: str,
228
+ index: int,
229
+ assignee: str | None = None,
230
+ assignees: list[str] | None = None,
231
+ body: str | None = None,
232
+ due_date: datetime | None = None,
233
+ milestone: int | None = None,
234
+ ref: str | None = None,
235
+ state: Literal["closed", "open"] | None = None,
236
+ title: str | None = None,
237
+ unset_due_date: bool | None = None,
238
+ **kwargs: Any,
239
+ ) -> tuple[dict[str, Any], int]:
240
+ """Edit a specific issue in a repository.
241
+
242
+ Args:
243
+ owner: The owner of the repository.
244
+ repository: The name of the repository.
245
+ index: The index of the issue.
246
+ assignee: The new assignee of the issue.
247
+ assignees: The new assignees of the issue.
248
+ body: The new body of the issue.
249
+ due_date: The new due date of the issue.
250
+ milestone: The new milestone of the issue.
251
+ ref: The new reference of the issue.
252
+ state: The new state of the issue.
253
+ title: The new title of the issue.
254
+ unset_due_date: Whether to unset the due date of the issue.
255
+ **kwargs: Additional arguments for the request.
256
+
257
+ Returns:
258
+ A tuple containing the edited issue as a dictionary and the status code.
259
+
260
+ """
261
+ response = await self._edit_issue(
262
+ owner=owner,
263
+ repository=repository,
264
+ index=index,
265
+ assignee=assignee,
266
+ assignees=assignees,
267
+ body=body,
268
+ due_date=due_date,
269
+ milestone=milestone,
270
+ ref=ref,
271
+ state=state,
272
+ title=title,
273
+ unset_due_date=unset_due_date,
274
+ **kwargs,
275
+ )
276
+ data, status_code = await process_async_response(response)
277
+ return cast(dict[str, Any], data), status_code