Skip to content

Commit 11a9c6a

Browse files
Expanding docstrings for reporters (#2904)
Expanding docstrings for reporters Additional documentation for methods of reporters. Reviewed-by: gemini-code-assist[bot] Reviewed-by: Laura Barcziová
2 parents 079d040 + 4af93cd commit 11a9c6a

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

packit_service/worker/reporting/reporters/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def get_instance(
5353
) -> "StatusReporter":
5454
"""
5555
Get the StatusReporter instance.
56+
The `project` determines type of the reporter returned. All other
57+
parameters are passed to the initializer of the chosen reporter.
5658
"""
5759
from .github import StatusReporterGithubChecks
5860
from .gitlab import StatusReporterGitlab
@@ -105,6 +107,7 @@ def set_status(
105107
markdown_content: Optional[str] = None,
106108
target_branch: Optional[str] = None,
107109
):
110+
"""Set status of the check."""
108111
raise NotImplementedError()
109112

110113
def report(
@@ -130,7 +133,7 @@ def report(
130133
e.g. `{"Testing Farm": "url-to-testing-farm"}`
131134
132135
Defaults to None
133-
check_names: Those in bold.
136+
check_names: List of check names
134137
135138
Defaults to None
136139
markdown_content: In GitHub checks, we can provide a markdown content.

packit_service/worker/reporting/reporters/github.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def set_status(
100100
markdown_content: Optional[str] = None,
101101
target_branch: Optional[str] = None,
102102
):
103+
"""
104+
Set status of a Github check.
105+
106+
When encountering `GithubAPIException` falls back to setting
107+
Github status directly.
108+
"""
109+
103110
markdown_content = markdown_content or ""
104111
state_to_set = self.get_check_run(state)
105112
logger.debug(

packit_service/worker/reporting/reporters/gitlab.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ def set_status(
3333
markdown_content: Optional[str] = None,
3434
target_branch: Optional[str] = None,
3535
):
36+
"""
37+
Set status of a Gitlab check.
38+
39+
Discards `markdown_content`, as it isn't supported by Gitlab.
40+
If attempt to set status of a commit fails with `GitlabAPIException`
41+
and error code 400, 403 or 404, it attempts to add a comment instead.
42+
"""
43+
3644
state_to_set = self.get_commit_status(state)
3745
logger.debug(
3846
f"Setting Gitlab status '{state_to_set.name}' for check '{check_name}': {description}",

packit_service/worker/reporting/reporters/pagure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def set_status(
3434
markdown_content: Optional[str] = None,
3535
target_branch: Optional[str] = None,
3636
):
37+
"""
38+
Set status of a Pagure check.
39+
40+
If used for a pull request, the UID is derived from SHA256
41+
of `check_name` or combination of `check_name` and `target_branch`.
42+
43+
Value of `url` defaults to `CONTACTS_URL`, since Pagure requires
44+
some URL to be submitted.
45+
"""
3746
state_to_set = self.get_commit_status(state)
3847
logger.debug(
3948
f"Setting Pagure status '{state_to_set.name}' for check '{check_name}' and "

0 commit comments

Comments
 (0)