From 988ce0fe31ae1d455b7eb50583095abd19ced4ac Mon Sep 17 00:00:00 2001 From: nicko4o Date: Fri, 9 Jan 2026 18:45:39 +0800 Subject: [PATCH] fix: resolve Lahman data loading and remove debug output - lahman.py: Update URL from deprecated chadwickbureau to seanlahman - lahman.py: Add Master.csv/People.csv fallback for compatibility - team_results.py: Remove debug print(url) statement Fixes: #489 (Lahman loading) --- pybaseball/lahman.py | 8 ++++++-- pybaseball/team_results.py | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pybaseball/lahman.py b/pybaseball/lahman.py index 437096eb..5a9a04cf 100644 --- a/pybaseball/lahman.py +++ b/pybaseball/lahman.py @@ -8,7 +8,7 @@ from . import cache -url = "https://github.com/chadwickbureau/baseballdatabank/archive/master.zip" +url = "https://github.com/seanlahman/baseballdatabank/archive/refs/heads/master.zip" base_string = "baseballdatabank-master" _handle = None @@ -106,7 +106,11 @@ def master() -> pd.DataFrame: return people() def people() -> pd.DataFrame: - return _get_file("core/People.csv") + # Try new naming first (People.csv), fallback to old naming (Master.csv) + try: + return _get_file("core/People.csv") + except (FileNotFoundError, KeyError): + return _get_file("core/Master.csv") def pitching() -> pd.DataFrame: return _get_file("core/Pitching.csv") diff --git a/pybaseball/team_results.py b/pybaseball/team_results.py index 6e7c44ce..b4e802f8 100644 --- a/pybaseball/team_results.py +++ b/pybaseball/team_results.py @@ -19,7 +19,6 @@ def get_soup(season: Optional[int], team: str) -> BeautifulSoup: if season is None: season = most_recent_season() url = "https://www.baseball-reference.com/teams/{}/{}-schedule-scores.shtml".format(team, season) - print(url) s = session.get(url).content return BeautifulSoup(s, "lxml")