Seeking Help: Filtering Issues without Associated Pull Requests in GitHub

Hello everyone,

I’m currently working on a Python project and I’m facing a challenge in filtering issues from a repository that don’t have any associated pull requests. I would greatly appreciate it if someone could help me with this issue.

Here’s the code snippet I’m using:

pythonCopy code

new_issues = []

for index, row in contributor_filtered_df.iterrows():
    contributor = row["assignee"]
    issues = repo.get_issues(state="open", assignee=contributor)
    for issue in issues:
        if not any(pr.number == issue.number for pr in pull_requests):

new_issues = list({issue.number: issue for issue in new_issues}.values())

# Print the new issues
print("New Issues:")
for issue in new_issues:
    print(f"Issue Title: {issue.title}")
    print(f"Issue Number: {issue.number}")
    print(f"Issue URL: {issue.html_url}")

I’m trying to obtain a list of issues that are assigned to specific contributors but don’t have any associated pull requests. However, I’m encountering some issues with the code.

If anyone could help me understand and resolve this issue, I would be extremely grateful. If you need the full code ask me

Thank you in advance for your assistance!


Your snippet looks reasonable, the only thing that stands out to me is this:

I think the major Git web hosts do not associate issues and pull requests this way. On GitHub for instance, issue numbers and pull request numbers draw from the same sequence of IDs - an issue and a PR will never have the same number. Similarly on GitLab, I don’t think there is a correlation between an issue number and PR number - they are just sequential, so the 5th issue might be associated with the 7th pull request, it just depends on what order different things were opened and closed.

In the GitHub API it looks like Pull Request objects have an attribute for “closing issues”, but I haven’t been able to find a matching attribute for Issues with associated Pull Requests.

Exactly what attributes or links to use would depend on the Git service, what data you have access to, and what Python library (if any) you’re using to get your repository information.