From 0497dd3d43109597b321aa90a23f5a3bc879a923 Mon Sep 17 00:00:00 2001 From: Partha Shirolkar Date: Thu, 8 Jan 2026 16:24:00 +0530 Subject: [PATCH] fix(parameters): add NBA Cup and IST season type constants Resolves #620 - Add nba_cup = "NBA Cup" to SeasonType base class - Add ist = "IST" to SeasonType base class - Update all season type tests to validate new constants - Constants inherited by SeasonTypePlayoffs, SeasonTypeAllStar, SeasonTypeNullable, and SeasonTypeAllStarNullable classes Users can now use SeasonTypeAllStar.nba_cup or SeasonTypeAllStar.ist instead of raw string literals. --- src/nba_api/stats/library/parameters.py | 2 + tests/unit/test_parameters.py | 84 +++++++++++++++---------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/nba_api/stats/library/parameters.py b/src/nba_api/stats/library/parameters.py index ce270ff6..eb7beebd 100644 --- a/src/nba_api/stats/library/parameters.py +++ b/src/nba_api/stats/library/parameters.py @@ -709,6 +709,8 @@ class SeasonType: regular = "Regular Season" preseason = "Pre Season" playin = "PlayIn" + nba_cup = "NBA Cup" + ist = "IST" default = regular diff --git a/tests/unit/test_parameters.py b/tests/unit/test_parameters.py index c5e2b674..e568d540 100644 --- a/tests/unit/test_parameters.py +++ b/tests/unit/test_parameters.py @@ -1,11 +1,11 @@ from nba_api.stats.library.parameters import ( - Season, - SeasonType, - SeasonTypePlayoffs, - SeasonTypeAllStar, + Season, + SeasonType, + SeasonTypePlayoffs, + SeasonTypeAllStar, SeasonTypeNullable, SeasonTypeAllStarNullable, - _NotRequired + _NotRequired, ) import re @@ -18,12 +18,16 @@ def test_season_type_base(): assert SeasonType.regular == "Regular Season" assert SeasonType.preseason == "Pre Season" assert SeasonType.playin == "PlayIn" + assert SeasonType.nba_cup == "NBA Cup" + assert SeasonType.ist == "IST" assert SeasonType.default == "Regular Season" - assert hasattr(SeasonType, 'regular') - assert hasattr(SeasonType, 'preseason') - assert hasattr(SeasonType, 'playin') - assert not hasattr(SeasonType, 'playoffs') - assert not hasattr(SeasonType, 'all_star') + assert hasattr(SeasonType, "regular") + assert hasattr(SeasonType, "preseason") + assert hasattr(SeasonType, "playin") + assert hasattr(SeasonType, "nba_cup") + assert hasattr(SeasonType, "ist") + assert not hasattr(SeasonType, "playoffs") + assert not hasattr(SeasonType, "all_star") def test_season_type_playoffs(): @@ -31,12 +35,16 @@ def test_season_type_playoffs(): assert SeasonTypePlayoffs.preseason == "Pre Season" assert SeasonTypePlayoffs.playoffs == "Playoffs" assert SeasonTypePlayoffs.playin == "PlayIn" + assert SeasonTypePlayoffs.nba_cup == "NBA Cup" + assert SeasonTypePlayoffs.ist == "IST" assert SeasonTypePlayoffs.default == "Regular Season" - assert hasattr(SeasonTypePlayoffs, 'regular') - assert hasattr(SeasonTypePlayoffs, 'preseason') - assert hasattr(SeasonTypePlayoffs, 'playoffs') - assert hasattr(SeasonTypePlayoffs, 'playin') - assert not hasattr(SeasonTypePlayoffs, 'all_star') + assert hasattr(SeasonTypePlayoffs, "regular") + assert hasattr(SeasonTypePlayoffs, "preseason") + assert hasattr(SeasonTypePlayoffs, "playoffs") + assert hasattr(SeasonTypePlayoffs, "playin") + assert hasattr(SeasonTypePlayoffs, "nba_cup") + assert hasattr(SeasonTypePlayoffs, "ist") + assert not hasattr(SeasonTypePlayoffs, "all_star") def test_season_type_all_star(): @@ -45,12 +53,16 @@ def test_season_type_all_star(): assert SeasonTypeAllStar.playoffs == "Playoffs" assert SeasonTypeAllStar.playin == "PlayIn" assert SeasonTypeAllStar.all_star == "All Star" + assert SeasonTypeAllStar.nba_cup == "NBA Cup" + assert SeasonTypeAllStar.ist == "IST" assert SeasonTypeAllStar.default == "Regular Season" - assert hasattr(SeasonTypeAllStar, 'regular') - assert hasattr(SeasonTypeAllStar, 'preseason') - assert hasattr(SeasonTypeAllStar, 'playoffs') - assert hasattr(SeasonTypeAllStar, 'playin') - assert hasattr(SeasonTypeAllStar, 'all_star') + assert hasattr(SeasonTypeAllStar, "regular") + assert hasattr(SeasonTypeAllStar, "preseason") + assert hasattr(SeasonTypeAllStar, "playoffs") + assert hasattr(SeasonTypeAllStar, "playin") + assert hasattr(SeasonTypeAllStar, "all_star") + assert hasattr(SeasonTypeAllStar, "nba_cup") + assert hasattr(SeasonTypeAllStar, "ist") def test_season_type_nullable(): @@ -58,14 +70,18 @@ def test_season_type_nullable(): assert SeasonTypeNullable.preseason == "Pre Season" assert SeasonTypeNullable.playoffs == "Playoffs" assert SeasonTypeNullable.playin == "PlayIn" + assert SeasonTypeNullable.nba_cup == "NBA Cup" + assert SeasonTypeNullable.ist == "IST" assert SeasonTypeNullable.none == "" assert SeasonTypeNullable.default == "" - assert hasattr(SeasonTypeNullable, 'regular') - assert hasattr(SeasonTypeNullable, 'preseason') - assert hasattr(SeasonTypeNullable, 'playoffs') - assert hasattr(SeasonTypeNullable, 'playin') - assert hasattr(SeasonTypeNullable, 'none') - assert not hasattr(SeasonTypeNullable, 'all_star') + assert hasattr(SeasonTypeNullable, "regular") + assert hasattr(SeasonTypeNullable, "preseason") + assert hasattr(SeasonTypeNullable, "playoffs") + assert hasattr(SeasonTypeNullable, "playin") + assert hasattr(SeasonTypeNullable, "nba_cup") + assert hasattr(SeasonTypeNullable, "ist") + assert hasattr(SeasonTypeNullable, "none") + assert not hasattr(SeasonTypeNullable, "all_star") def test_season_type_all_star_nullable(): @@ -73,14 +89,18 @@ def test_season_type_all_star_nullable(): assert SeasonTypeAllStarNullable.preseason == "Pre Season" assert SeasonTypeAllStarNullable.playoffs == "Playoffs" assert SeasonTypeAllStarNullable.playin == "PlayIn" + assert SeasonTypeAllStarNullable.nba_cup == "NBA Cup" + assert SeasonTypeAllStarNullable.ist == "IST" assert SeasonTypeAllStarNullable.none == "" assert SeasonTypeAllStarNullable.default == "" - assert hasattr(SeasonTypeAllStarNullable, 'regular') - assert hasattr(SeasonTypeAllStarNullable, 'preseason') - assert hasattr(SeasonTypeAllStarNullable, 'playoffs') - assert hasattr(SeasonTypeAllStarNullable, 'playin') - assert hasattr(SeasonTypeAllStarNullable, 'none') - assert not hasattr(SeasonTypeAllStarNullable, 'all_star') + assert hasattr(SeasonTypeAllStarNullable, "regular") + assert hasattr(SeasonTypeAllStarNullable, "preseason") + assert hasattr(SeasonTypeAllStarNullable, "playoffs") + assert hasattr(SeasonTypeAllStarNullable, "playin") + assert hasattr(SeasonTypeAllStarNullable, "nba_cup") + assert hasattr(SeasonTypeAllStarNullable, "ist") + assert hasattr(SeasonTypeAllStarNullable, "none") + assert not hasattr(SeasonTypeAllStarNullable, "all_star") def test_season_type_inheritance():