You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
discussions.py sends its GraphQL query with a direct requests.post call. When we migrated the rest of the action from github3.py to PyGithub (#789), this left requests as the one direct dependency that PyGithub does not cover, so we had to re-declare requests==2.34.2 (and types-requests) in pyproject.toml just to keep that single module working. Every other GitHub call now goes through PyGithub. If PyGithub ever swaps its HTTP backend, import discussions would break at load time.
For context, discussions.py predates the PyGithub move. github3.py had no Discussions support, so the original code reached for requests to hit the GraphQL API directly.
Describe the solution you'd like
Move get_discussions() onto PyGithub's GraphQL support and drop the direct requests usage:
PyGithub 2.9.1 exposes github_connection.requester.graphql_query(query, variables) (via the public requester property), which returns (headers, data) and reuses PyGithub's auth, base URL, and GitHub Enterprise /api/graphql handling.
Refactor get_discussions() to accept the Github connection instead of the raw token and ghe, then call graphql_query with the existing query string.
Once nothing imports requests directly, remove requests from dependencies and types-requests from the dev dependencies in pyproject.toml, and refresh uv.lock.
Confirm the Enterprise path: verify graphql_query builds the /api/graphql endpoint correctly for a GH_ENTERPRISE_URL base URL.
Update test_discussions.py, which currently patches requests.post, to mock the PyGithub GraphQL call instead.
Describe alternatives you've considered
Keep requests as a direct dependency (what we did in refactor: migrate from github3.py to PyGithub #789). It works, but it keeps a second HTTP client in the tree for one module and relies on us remembering it is a real direct dependency.
Wait for a high-level PyGithub Discussions object. PyGithub 2.9.1 has RepositoryDiscussion* classes but no object for a global search(type: DISCUSSION) query, so there is no drop-in replacement today. graphql_query is the available path.
Additional context
Follow-up from the PyGithub migration in #789. graphql_query is a lower-level method rather than a documented high-level API, so this is worth a small spike to confirm the return shape and Enterprise handling before committing to it.
Is your feature request related to a problem?
discussions.pysends its GraphQL query with a directrequests.postcall. When we migrated the rest of the action from github3.py to PyGithub (#789), this leftrequestsas the one direct dependency that PyGithub does not cover, so we had to re-declarerequests==2.34.2(andtypes-requests) inpyproject.tomljust to keep that single module working. Every other GitHub call now goes through PyGithub. If PyGithub ever swaps its HTTP backend,import discussionswould break at load time.For context,
discussions.pypredates the PyGithub move. github3.py had no Discussions support, so the original code reached forrequeststo hit the GraphQL API directly.Describe the solution you'd like
Move
get_discussions()onto PyGithub's GraphQL support and drop the directrequestsusage:github_connection.requester.graphql_query(query, variables)(via the publicrequesterproperty), which returns(headers, data)and reuses PyGithub's auth, base URL, and GitHub Enterprise/api/graphqlhandling.get_discussions()to accept theGithubconnection instead of the rawtokenandghe, then callgraphql_querywith the existing query string.requestsdirectly, removerequestsfromdependenciesandtypes-requestsfrom the dev dependencies inpyproject.toml, and refreshuv.lock.graphql_querybuilds the/api/graphqlendpoint correctly for aGH_ENTERPRISE_URLbase URL.test_discussions.py, which currently patchesrequests.post, to mock the PyGithub GraphQL call instead.Describe alternatives you've considered
requestsas a direct dependency (what we did in refactor: migrate from github3.py to PyGithub #789). It works, but it keeps a second HTTP client in the tree for one module and relies on us remembering it is a real direct dependency.RepositoryDiscussion*classes but no object for a globalsearch(type: DISCUSSION)query, so there is no drop-in replacement today.graphql_queryis the available path.Additional context
Follow-up from the PyGithub migration in #789.
graphql_queryis a lower-level method rather than a documented high-level API, so this is worth a small spike to confirm the return shape and Enterprise handling before committing to it.