Skip to content

Commit 04e6f81

Browse files
rwood-97claude
andcommitted
Fix docstring issues across multiple modules
- Fix typo 'autheticated' -> 'authenticated' in utils.py (x2) - Add missing max_pages param to query_with_pagination docstring - Fix inaccurate/incomplete Returns sections in commits.py, repos.py, org_user_info.py, licences.py - Replace TODO placeholder in repo_contributors.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ea6ed04 commit 04e6f81

File tree

7 files changed

+96
-10
lines changed

7 files changed

+96
-10
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,84 @@ python -m pip install .
2020

2121
## Usage
2222

23+
### Authentication
24+
25+
All functions require a GitHub personal access token with appropriate
26+
permissions.
27+
28+
You will need to set it as an environment variable:
29+
30+
```bash
31+
export GITHUB_TOKEN=your_token_here
32+
```
33+
34+
### Functions
35+
36+
All functions return a pandas DataFrame and accept an optional `save` argument.
37+
38+
- Setting `save=True` will cause the data to be saved to `data/`
39+
- Setting `save="path/to/file.csv"` will cause the data to be saved to the
40+
specified path.
41+
42+
**Org-level data:**
43+
44+
```python
45+
from github_analyser.org_user_info import get_org_members, get_org_teams
46+
from github_analyser.repos import get_repos
47+
48+
# list all repositories in an organisation
49+
repos = get_repos("my-org")
50+
51+
# list all members of an organisation
52+
members = get_org_members("my-org")
53+
54+
# list all teams in an organisation
55+
teams = get_org_teams("my-org")
56+
```
57+
58+
**Team and repo-level data:**
59+
60+
```python
61+
from github_analyser.team_user_info import get_team_members
62+
from github_analyser.repo_user_info import get_repo_collaborators
63+
from github_analyser.repo_contributors import get_repo_contributors
64+
from github_analyser.commits import get_commits
65+
from github_analyser.issues import get_issues
66+
from github_analyser.pull_requests import get_pull_requests
67+
from github_analyser.licences import get_licences
68+
69+
# list members of a team (use the team slug, e.g. "my-team")
70+
members = get_team_members("my-org", "my-team")
71+
72+
# list collaborators of a repository
73+
collaborators = get_repo_collaborators("my-org", "my-repo")
74+
75+
# get contributor commit counts for a repository
76+
contributors = get_repo_contributors("my-org", "my-repo")
77+
78+
# get commits from the default branch of a repository
79+
commits = get_commits("my-org", "my-repo")
80+
81+
# get issues from a repository
82+
issues = get_issues("my-org", "my-repo")
83+
84+
# get pull requests from a repository
85+
prs = get_pull_requests("my-org", "my-repo")
86+
87+
# get licence information for one or more repositories
88+
licences = get_licences("my-org", ["repo-one", "repo-two"])
89+
```
90+
91+
**Saving results to CSV:**
92+
93+
```python
94+
# save to the default path
95+
repos = get_repos("my-org", save=True)
96+
97+
# save to a custom path
98+
repos = get_repos("my-org", save="output/repos.csv")
99+
```
100+
23101
## Contributing
24102

25103
See [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.

src/github_analyser/commits.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@ def get_commits(
6565
6666
Returns:
6767
A pandas DataFrame with the following columns:
68-
- message: The commit message.
69-
- additions: The number of additions in the commit.
70-
- deletions: The number of deletions in the commit.
68+
- id: The commit node ID.
69+
- hash: The commit SHA.
70+
- message: The commit message headline.
7171
- author: The author of the commit.
7272
- date: The date of the commit.
73+
- changed_files: The number of files changed.
74+
- additions: The number of line additions.
75+
- deletions: The number of line deletions.
76+
- pr_id: The ID of the associated pull request, if any.
77+
- repo_id: The repository node ID.
7378
"""
7479
query = _get_commits_query(org_name, repo_name)
7580

src/github_analyser/licences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_licence(
3434
repo_name: The name of the repository.
3535
3636
Returns:
37-
A pandas Series containing the repository ID, licence name, and SPDX ID.
37+
A pandas Series containing the repository name, URL, ID, licence name, and SPDX ID.
3838
"""
3939
query = _get_licence_query(org_name, repo_name)
4040

src/github_analyser/org_user_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def get_org_teams(org_name: str, save: bool | str = False):
9595
specify a path. Defaults to False.
9696
9797
Returns:
98-
pandas Dataframe: One row per team, columns name.
98+
pandas Dataframe: One row per team, with columns name, slug, and id.
9999
"""
100100
pages = query_with_pagination(
101101
_get_org_teams_query(org_name),

src/github_analyser/repo_contributors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def get_repo_contributors(
2020
2121
Returns:
2222
A pandas DataFrame with the following columns:
23-
TODO
23+
- login: The GitHub username of the contributor.
24+
- commits: The total number of commits by the contributor.
2425
"""
2526
data = request_github_rest(
2627
"get", f"repos/{org_name}/{repo_name}/stats/contributors"

src/github_analyser/repos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def get_repos(org_name: str, save: bool | str = False):
5151
specify a path. Defaults to False.
5252
5353
Returns:
54-
pandas Dataframe: One row per repo, columns repository name, id, url and last
55-
updated date.
54+
pandas Dataframe: One row per repo, with columns id, name, updated_at, url,
55+
is_private, is_archived, is_fork, and languages.
5656
"""
5757
pages = query_with_pagination(
5858
_get_repos_query(org_name),

src/github_analyser/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def request_github_rest(
2222
max_tries: int = 10,
2323
sleep_time: float = 1.0,
2424
) -> Any:
25-
"""Run an autheticated query against the GitHub API.
25+
"""Run an authenticated query against the GitHub API.
2626
2727
Assumes that the GitHub token is set in the environment variable GITHUB_TOKEN.
2828
@@ -57,7 +57,7 @@ def request_github_rest(
5757

5858

5959
def request_github_graphql(payload: Any, headers: Any | None = None) -> Any:
60-
"""Run an autheticated query against the GitHub API.
60+
"""Run an authenticated query against the GitHub API.
6161
6262
Assumes that the GitHub token is set in the environment variable GITHUB_TOKEN.
6363
@@ -98,6 +98,8 @@ def query_with_pagination(
9898
means no pagination is done and the return value will be a list of length 1.
9999
cursor_variable_name: The name of the cursor variable in the query.
100100
"pagination_cursor" by default.
101+
max_pages: The maximum number of pages to fetch. Optional, default is None
102+
(fetch all pages).
101103
102104
Returns:
103105
A list of responses from the GitHub API as JSON.

0 commit comments

Comments
 (0)