Skip to content

Commit 90adba4

Browse files
committed
latest_season returns first season which hasn't ended
1 parent e949dcd commit 90adba4

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
@@ -1209,14 +1209,11 @@ def latest_season(sportId=1):
12091209
all_seasons = get("season", params)
12101210
return next(
12111211
(
1212-
x
1213-
for x in all_seasons.get("seasons", [])
1214-
if x.get("seasonStartDate")
1215-
and x.get("seasonEndDate")
1216-
and (
1217-
x["seasonStartDate"]
1218-
< datetime.today().strftime("%Y-%m-%d")
1219-
< x["seasonEndDate"]
1212+
s
1213+
for s in all_seasons.get("seasons", [])
1214+
if (
1215+
datetime.today().strftime("%Y-%m-%d")
1216+
< s.get("seasonEndDate", "")
12201217
)
12211218
),
12221219
all_seasons["seasons"][-1],

0 commit comments

Comments
 (0)