From 7edc56a7866d04a4cebe3a37dbd7cbd46bb01348 Mon Sep 17 00:00:00 2001 From: yasumorishima Date: Wed, 4 Feb 2026 20:30:58 +0900 Subject: [PATCH] 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 --- pybaseball/retrosheet.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pybaseball/retrosheet.py b/pybaseball/retrosheet.py index 391f55bb..7063900c 100644 --- a/pybaseball/retrosheet.py +++ b/pybaseball/retrosheet.py @@ -24,7 +24,7 @@ from pybaseball.utils import get_text_file from datetime import datetime from io import StringIO -from github import Github +from github import Auth, Github import os from getpass import getuser, getpass from github.GithubException import RateLimitExceededException @@ -131,7 +131,7 @@ def events(season, type='regular', export_dir='.'): "the valid types are: 'regular', 'post', and 'asg'.") try: - g = Github(GH_TOKEN) + g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github() repo = g.get_repo('chadwickbureau/retrosheet') season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')] season_events = [t for t in season_folder if t.endswith(file_extension)] @@ -156,7 +156,7 @@ def rosters(season): GH_TOKEN=os.getenv('GH_TOKEN', '') try: - g = Github(GH_TOKEN) + g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github() repo = g.get_repo('chadwickbureau/retrosheet') season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')] rosters = [t for t in season_folder if t.endswith('.ROS')] @@ -179,7 +179,7 @@ def _roster(team, season, checked = False): GH_TOKEN=os.getenv('GH_TOKEN', '') if not checked: - g = Github(GH_TOKEN) + g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github() try: repo = g.get_repo('chadwickbureau/retrosheet') season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')] @@ -213,7 +213,7 @@ def schedules(season): """ GH_TOKEN=os.getenv('GH_TOKEN', '') # validate input - g = Github(GH_TOKEN) + g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github() repo = g.get_repo('chadwickbureau/retrosheet') season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')] file_name = f'{season}schedule.csv' @@ -231,7 +231,7 @@ def season_game_logs(season): """ GH_TOKEN=os.getenv('GH_TOKEN', '') # validate input - g = Github(GH_TOKEN) + g = Github(auth=Auth.Token(GH_TOKEN)) if GH_TOKEN else Github() repo = g.get_repo('chadwickbureau/retrosheet') season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')] gamelog_file_name = f'GL{season}.TXT'