`PullRequest.merged_by` return type should be `NamedUser | None`
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
Start in PullRequest.py at the merged_by property around line 367, and compare its annotation with the GitHub Pull Request object schema linked in the issue. Done means the annotation reflects that the API may return None while preserving the existing property behavior.
Written by the indexing model from the issue text.
Description
Problem
PullRequest.merged_by is typed as returning NamedUser, but the GitHub API can return null for this field on merged pull requests. This causes an AttributeError at runtime when accessing .login or other attributes on the result.
pr = repo.get_pull(123)
print(pr.merged_by.login) # AttributeError: 'NoneType' object has no attribute 'login'
When does this happen?
merged_by is null when a PR is implicitly merged — i.e., someone pushes the PR's commits directly to the base branch (e.g., git push to main) rather than using GitHub's merge button. GitHub detects the commits are now in the base branch and closes the PR as "merged," but since no one clicked the merge button, there is no merged_by user.
This also shows up in webhook payloads (pull_request event with action: closed and merged: true), where the merged_by field is null.
Current type annotation
# PullRequest.py line 367
@property
def merged_by(self) -> NamedUser:
self._completeIfNotSet(self._merged_by)
return self._merged_by.value
Expected type annotation
@property
def merged_by(self) -> NamedUser | None:
...
This is consistent with how the GitHub REST API documents the field — the Pull Request object schema shows merged_by as nullable.
Version
PyGithub 2.9.1, Python 3.13
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 1.9k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyGithub/PyGithub
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
All issues in PyGithub/PyGithub
Similar issues
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100