Skip to content

Commit ae1d2d9

Browse files
authored
Merge pull request #157 from WardBrian/fix/152-latest-season
latest_season returns first season which hasn't ended
2 parents 63369fa + 90adba4 commit ae1d2d9

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

statsapi/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,14 +1213,11 @@ def latest_season(sportId=1):
12131213
all_seasons = get("season", params)
12141214
return next(
12151215
(
1216-
x
1217-
for x in all_seasons.get("seasons", [])
1218-
if x.get("seasonStartDate")
1219-
and x.get("seasonEndDate")
1220-
and (
1221-
x["seasonStartDate"]
1222-
< datetime.today().strftime("%Y-%m-%d")
1223-
< x["seasonEndDate"]
1216+
s
1217+
for s in all_seasons.get("seasons", [])
1218+
if (
1219+
datetime.today().strftime("%Y-%m-%d")
1220+
< s.get("seasonEndDate", "")
12241221
)
12251222
),
12261223
all_seasons["seasons"][-1],

0 commit comments

Comments
 (0)