Skip to content

Commit af7ef86

Browse files
committed
Consolidate on one test
1 parent 2865636 commit af7ef86

File tree

3 files changed

+50
-18
lines changed

3 files changed

+50
-18
lines changed

github_activity/github_activity.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ def generate_activity_md(
472472
bot_users = data.attrs["bot_users"]
473473

474474
def ignored_user(username):
475-
if not username:
475+
# Handle None, empty strings, and non-string types (like NaN)
476+
if not username or not isinstance(username, str):
476477
return False
477478

478479
# First check against GraphQL-detected bot users
@@ -561,17 +562,19 @@ def filter_ignored(userlist):
561562
item_commenters_counts >= comment_response_cutoff
562563
].index.tolist()
563564
for person in item_commenters_counts:
564-
all_contributors.add(person)
565+
# Filter out NaN values and non-strings
566+
if isinstance(person, str):
567+
all_contributors.add(person)
565568

566569
# record contributor list (ordered, unique)
567570
data.at[ix, "contributors"] = list(item_contributors)
568571

569572
comment_contributor_counts = pd.Series(comment_helpers).value_counts()
570-
all_contributors |= set(
571-
comment_contributor_counts[
572-
comment_contributor_counts >= comment_others_cutoff
573-
].index.tolist()
574-
)
573+
# Filter out NaN values and non-strings
574+
comment_contributors = comment_contributor_counts[
575+
comment_contributor_counts >= comment_others_cutoff
576+
].index.tolist()
577+
all_contributors |= set(c for c in comment_contributors if isinstance(c, str))
575578

576579
# Filter the PRs by branch (or ref) if given
577580
if branch is not None:
@@ -610,7 +613,9 @@ def filter_ignored(userlist):
610613
closed_prs = closed_prs.query("state != 'CLOSED'")
611614

612615
# Add any contributors to a merged PR to our contributors list
613-
all_contributors |= set(closed_prs["contributors"].explode().unique().tolist())
616+
# Filter out NaN values and non-strings
617+
pr_contributors = closed_prs["contributors"].explode().unique().tolist()
618+
all_contributors |= set(c for c in pr_contributors if isinstance(c, str))
614619

615620
# Define categories for a few labels
616621
if tags is None:

tests/test_cli.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def test_changelog_features(file_regression):
109109
until = "v1.1.0"
110110

111111
# Test general changelog structure with a regression test
112+
# PRs should be split by issue label.
112113
md_full = generate_activity_md(
113114
target=f"{org}/{repo}",
114115
since=since,
@@ -117,21 +118,17 @@ def test_changelog_features(file_regression):
117118
)
118119
file_regression.check(md_full, basename="test_cli_all", extension=".md")
119120

120-
# Test that PRs are split into multiple sections
121-
md_split = md_full.split("## Contributors to this release")[0]
122-
file_regression.check(md_split, basename="test_pr_split", extension=".md")
123-
124121
# Test that contributor sorting works, minus @choldgraf since we filtered him out (sorry Chris)
125122
assert (
126123
"- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))"
127124
in md_full
128125
), "Contributors should be sorted as expected"
129126

130127
# Test that ignored usernames are ignored
131-
assert "choldgraf" not in md_full.lower(), (
128+
assert "@choldgraf" not in md_full.lower(), (
132129
"Ignored contributor should not appear in output"
133130
)
134131
# Test that bots are removed
135-
assert "dependabot" not in md_full.lower(), (
132+
assert "@dependabot" not in md_full.lower(), (
136133
"Bot user dependabot should not appear in output"
137134
)

tests/test_cli/test_cli_all.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1-
# v1.0.2...v1.0.3
1+
# v1.0.2...v1.1.0
22

3-
([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.0.3))
3+
([full changelog](https://github.com/executablebooks/github-activity/compare/v1.0.2...v1.1.0))
4+
5+
## Enhancements made
6+
7+
- Allow excluding certain usernames from changelog [#128](https://github.com/executablebooks/github-activity/pull/128) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))
8+
9+
## Bugs fixed
10+
11+
- Add `pytz` to requirements [#147](https://github.com/executablebooks/github-activity/pull/147) ([@jtpio](https://github.com/jtpio), [@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))
12+
- Ensure PRs only show up once per changelog [#130](https://github.com/executablebooks/github-activity/pull/130) ([@bsipocz](https://github.com/bsipocz), [@nabobalis](https://github.com/nabobalis))
13+
14+
## Maintenance and upkeep improvements
15+
16+
- MAINT: group the dependabot updates into one PR [#141](https://github.com/executablebooks/github-activity/pull/141) ([@bsipocz](https://github.com/bsipocz))
17+
- Expose GitHub API call error [#138](https://github.com/executablebooks/github-activity/pull/138) ([@stefanv](https://github.com/stefanv))
18+
- Update pre-commit to use Ruff; update versions and add a few rules [#137](https://github.com/executablebooks/github-activity/pull/137) ([@stefanv](https://github.com/stefanv), [@bsipocz](https://github.com/bsipocz))
19+
- Change token to readonly PAT so we don't hit rate limits [#134](https://github.com/executablebooks/github-activity/pull/134) ([@bsipocz](https://github.com/bsipocz))
20+
- Fix tests and move contributing docs into our docs [#133](https://github.com/executablebooks/github-activity/pull/133) ()
421

522
## Documentation improvements
623

24+
- make sure generated anchor links resolve [#122](https://github.com/executablebooks/github-activity/pull/122) ([@minrk](https://github.com/minrk), [@consideRatio](https://github.com/consideRatio))
725
- Add changelog for v1.0.3 [#120](https://github.com/executablebooks/github-activity/pull/120) ([@consideRatio](https://github.com/consideRatio))
826
- Add changelog for v1.0.2 [#117](https://github.com/executablebooks/github-activity/pull/117) ([@consideRatio](https://github.com/consideRatio))
927

@@ -12,11 +30,23 @@
1230
- ci: fix github action tag in publish workflow [#119](https://github.com/executablebooks/github-activity/pull/119) ([@consideRatio](https://github.com/consideRatio))
1331
- ci: fix location of dependabot.yaml [#118](https://github.com/executablebooks/github-activity/pull/118) ([@consideRatio](https://github.com/consideRatio))
1432

33+
## Other merged PRs
34+
35+
- RLS: v1.1.0 [#149](https://github.com/executablebooks/github-activity/pull/149) ()
36+
- Use GraphQL API for bot detection [#146](https://github.com/executablebooks/github-activity/pull/146) ([@stefanv](https://github.com/stefanv))
37+
- Update test suite to use fewer GitHub API calls [#144](https://github.com/executablebooks/github-activity/pull/144) ([@bsipocz](https://github.com/bsipocz), [@stefanv](https://github.com/stefanv))
38+
- Bump actions/checkout from 5 to 6 in the actions group [#143](https://github.com/executablebooks/github-activity/pull/143) ([@bsipocz](https://github.com/bsipocz))
39+
- Bump actions/checkout from 4 to 5 [#140](https://github.com/executablebooks/github-activity/pull/140) ([@bsipocz](https://github.com/bsipocz))
40+
- Bump actions/setup-python from 5 to 6 [#139](https://github.com/executablebooks/github-activity/pull/139) ([@bsipocz](https://github.com/bsipocz))
41+
- add pyproject.toml [#132](https://github.com/executablebooks/github-activity/pull/132) ([@minrk](https://github.com/minrk))
42+
- [DOC] Clarify some intended functionality in docs [#127](https://github.com/executablebooks/github-activity/pull/127) ([@manics](https://github.com/manics))
43+
- Use latest github release first instead of github tag [#125](https://github.com/executablebooks/github-activity/pull/125) ([@nabobalis](https://github.com/nabobalis))
44+
1545
## Contributors to this release
1646

1747
The following people contributed discussions, new ideas, code and documentation contributions, and review.
1848
See [our definition of contributors](https://github-activity.readthedocs.io/en/latest/#how-does-this-tool-define-contributions-in-the-reports).
1949

20-
([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-04-11&type=c))
50+
([GitHub contributors page for this release](https://github.com/executablebooks/github-activity/graphs/contributors?from=2025-04-11&to=2025-12-09&type=c))
2151

22-
@consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-04-11&type=Issues))
52+
@bsipocz ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Absipocz+updated%3A2025-04-11..2025-12-09&type=Issues)) | @consideRatio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3AconsideRatio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @jtpio ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Ajtpio+updated%3A2025-04-11..2025-12-09&type=Issues)) | @manics ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Amanics+updated%3A2025-04-11..2025-12-09&type=Issues)) | @minrk ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Aminrk+updated%3A2025-04-11..2025-12-09&type=Issues)) | @nabobalis ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Anabobalis+updated%3A2025-04-11..2025-12-09&type=Issues)) | @stefanv ([activity](https://github.com/search?q=repo%3Aexecutablebooks%2Fgithub-activity+involves%3Astefanv+updated%3A2025-04-11..2025-12-09&type=Issues))

0 commit comments

Comments
 (0)