Skip to content

Commit 7edc56a

Browse files
yasumorishimaclaude
andcommitted
Fix deprecated GitHub authentication in retrosheet.py (#455)
Replace deprecated `Github(token)` with `Github(auth=Auth.Token(token))` to avoid DeprecationWarning from PyGithub. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e588989 commit 7edc56a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

pybaseball/retrosheet.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from pybaseball.utils import get_text_file
2525
from datetime import datetime
2626
from io import StringIO
27-
from github import Github
27+
from github import Auth, Github
2828
import os
2929
from getpass import getuser, getpass
3030
from github.GithubException import RateLimitExceededException
@@ -131,7 +131,7 @@ def events(season, type='regular', export_dir='.'):
131131
"the valid types are: 'regular', 'post', and 'asg'.")
132132

133133
try:
134-
g = Github(GH_TOKEN)
134+
g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github()
135135
repo = g.get_repo('chadwickbureau/retrosheet')
136136
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
137137
season_events = [t for t in season_folder if t.endswith(file_extension)]
@@ -156,7 +156,7 @@ def rosters(season):
156156
GH_TOKEN=os.getenv('GH_TOKEN', '')
157157

158158
try:
159-
g = Github(GH_TOKEN)
159+
g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github()
160160
repo = g.get_repo('chadwickbureau/retrosheet')
161161
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
162162
rosters = [t for t in season_folder if t.endswith('.ROS')]
@@ -179,7 +179,7 @@ def _roster(team, season, checked = False):
179179
GH_TOKEN=os.getenv('GH_TOKEN', '')
180180

181181
if not checked:
182-
g = Github(GH_TOKEN)
182+
g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github()
183183
try:
184184
repo = g.get_repo('chadwickbureau/retrosheet')
185185
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
@@ -213,7 +213,7 @@ def schedules(season):
213213
"""
214214
GH_TOKEN=os.getenv('GH_TOKEN', '')
215215
# validate input
216-
g = Github(GH_TOKEN)
216+
g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github()
217217
repo = g.get_repo('chadwickbureau/retrosheet')
218218
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
219219
file_name = f'{season}schedule.csv'
@@ -231,7 +231,7 @@ def season_game_logs(season):
231231
"""
232232
GH_TOKEN=os.getenv('GH_TOKEN', '')
233233
# validate input
234-
g = Github(GH_TOKEN)
234+
g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github()
235235
repo = g.get_repo('chadwickbureau/retrosheet')
236236
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
237237
gamelog_file_name = f'GL{season}.TXT'

0 commit comments

Comments
 (0)