Skip to content

Commit bf44e72

Browse files
committed
remove access to pygithub's private requester
1 parent 5dd3298 commit bf44e72

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

dev/archery/archery/crossbow/core.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,9 @@ def as_github_repo(self, github_token=None):
465465
def token_expiration_date(self, github_token=None):
466466
"""Returns the expiration date for the github_token provided"""
467467
github = self._github_login(github_token)
468-
# NOTE: We access the private _Github__requester to get response
469-
# headers, as PyGithub doesn't expose the token expiration header
470-
# through its public API. This may break with future PyGithub updates.
471-
headers, _ = github._Github__requester.requestJsonAndCheck(
472-
"GET", "/user"
473-
)
468+
# PyGithub doesn't expose the token expiration header through a
469+
# dedicated API, so request it via the public Requester escape hatch.
470+
headers, _ = github.requester.requestJsonAndCheck("GET", "/user")
474471
# Response header in the form '2023-01-23 10:40:28 UTC'
475472
date_string = headers.get('github-authentication-token-expiration')
476473
if date_string:

dev/archery/archery/crossbow/tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_token_expiration_date():
207207
with mock.patch.object(Repo, '_github_login') as mock_login:
208208
mock_github = mock.MagicMock()
209209
mock_login.return_value = mock_github
210-
mock_github._Github__requester.requestJsonAndCheck.return_value = (
210+
mock_github.requester.requestJsonAndCheck.return_value = (
211211
{'github-authentication-token-expiration': '2024-12-31 23:59:59 UTC'},
212212
{}
213213
)
@@ -223,7 +223,7 @@ def test_token_expiration_date_no_header():
223223
with mock.patch.object(Repo, '_github_login') as mock_login:
224224
mock_github = mock.MagicMock()
225225
mock_login.return_value = mock_github
226-
mock_github._Github__requester.requestJsonAndCheck.return_value = (
226+
mock_github.requester.requestJsonAndCheck.return_value = (
227227
{},
228228
{}
229229
)

dev/archery/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
extras = {
3131
'benchmark': ['pandas'],
32-
'crossbow': ['pygithub', jinja_req, 'pygit2>=1.14.0', 'requests',
32+
'crossbow': ['pygithub>=2.5.0', jinja_req, 'pygit2>=1.14.0', 'requests',
3333
'ruamel.yaml', 'setuptools_scm>=8.0.0'],
3434
'docker': ['ruamel.yaml', 'python-dotenv'],
3535
'integration': ['cffi', 'numpy'],

0 commit comments

Comments
 (0)