From c8c3e5b43495fee8911a2e3a9915c26a74ce7010 Mon Sep 17 00:00:00 2001 From: martincham Date: Fri, 6 Sep 2024 17:21:50 -0400 Subject: [PATCH 1/6] add names --- espn_api/basketball/constant.py | 258 +++++++++++++++----------------- 1 file changed, 124 insertions(+), 134 deletions(-) diff --git a/espn_api/basketball/constant.py b/espn_api/basketball/constant.py index 04c2b2b1..86d9f6d8 100644 --- a/espn_api/basketball/constant.py +++ b/espn_api/basketball/constant.py @@ -1,149 +1,139 @@ POSITION_MAP = { - 0: 'PG', - 1: 'SG', - 2: 'SF', - 3: 'PF', - 4: 'C', - 5: 'G', - 6: 'F', - 7: 'SG/SF', - 8: 'G/F', - 9: 'PF/C', - 10: 'F/C', - 11: 'UT', - 12: 'BE', - 13: 'IR', - 14: '', - 15: 'Rookie', + 0: "PG", + 1: "SG", + 2: "SF", + 3: "PF", + 4: "C", + 5: "G", + 6: "F", + 7: "SG/SF", + 8: "G/F", + 9: "PF/C", + 10: "F/C", + 11: "UT", + 12: "BE", + 13: "IR", + 14: "", + 15: "Rookie", # reverse - 'PG': 0, - 'SG': 1, - 'SF': 2, - 'PF': 3, - 'C': 4, - 'G': 5, - 'F': 6, - 'SG/SF': 7, - 'G/F': 8, - 'PF/C': 9, - 'F/C': 10, - 'UT': 11, - 'BE': 12, - 'IR': 13, - 'Rookie': 15 + "PG": 0, + "SG": 1, + "SF": 2, + "PF": 3, + "C": 4, + "G": 5, + "F": 6, + "SG/SF": 7, + "G/F": 8, + "PF/C": 9, + "F/C": 10, + "UT": 11, + "BE": 12, + "IR": 13, + "Rookie": 15, } PRO_TEAM_MAP = { - 0: 'FA', - 1: 'ATL', - 2: 'BOS', - 3: 'NOP', - 4: 'CHI', - 5: 'CLE', - 6: 'DAL', - 7: 'DEN', - 8: 'DET', - 9: 'GSW', - 10: 'HOU', - 11: 'IND', - 12: 'LAC', - 13: 'LAL', - 14: 'MIA', - 15: 'MIL', - 16: 'MIN', - 17: 'BKN', - 18: 'NYK', - 19: 'ORL', - 20: 'PHL', - 21: 'PHO', - 22: 'POR', - 23: 'SAC', - 24: 'SAS', - 25: 'OKC', - 26: 'UTA', - 27: 'WAS', - 28: 'TOR', - 29: 'MEM', - 30: 'CHA', + 0: "FA", + 1: "ATL", + 2: "BOS", + 3: "NOP", + 4: "CHI", + 5: "CLE", + 6: "DAL", + 7: "DEN", + 8: "DET", + 9: "GSW", + 10: "HOU", + 11: "IND", + 12: "LAC", + 13: "LAL", + 14: "MIA", + 15: "MIL", + 16: "MIN", + 17: "BKN", + 18: "NYK", + 19: "ORL", + 20: "PHL", + 21: "PHO", + 22: "POR", + 23: "SAC", + 24: "SAS", + 25: "OKC", + 26: "UTA", + 27: "WAS", + 28: "TOR", + 29: "MEM", + 30: "CHA", } STATS_MAP = { - '0': 'PTS', - '1': 'BLK', - '2': 'STL', - '3': 'AST', - '4': 'OREB', - '5': 'DREB', - '6': 'REB', - '7': '7', - '8': '8', - '9': 'PF', - '10': '10', - '11': 'TO', - '12': '12', - '13': 'FGM', - '14': 'FGA', - '15': 'FTM', - '16': 'FTA', - '17': '3PTM', - '18': '3PTA', - '19': 'FG%', - '20': 'FT%', - '21': '3PT%', - '22': '22', - '23': '23', - '24': '24', - '25': '25', - '26': '26', - '27': '27', - '28': 'MPG', - '29': '29', - '30': '30', - '31': '31', - '32': '32', - '33': '33', - '34': '34', - '35': '35', - '36': '36', - '37': '37', - '38': '38', - '39': '39', - '40': 'MIN', - '41': 'GS', - '42': 'GP', - '43': '43', - '44': '44', - '45': '45', - } + "0": "PTS", + "1": "BLK", + "2": "STL", + "3": "AST", + "4": "OREB", + "5": "DREB", + "6": "REB", + "7": "EJ", + "8": "FF", + "9": "PF", + "10": "TF", + "11": "TO", + "12": "DQ", + "13": "FGM", + "14": "FGA", + "15": "FTM", + "16": "FTA", + "17": "3PM", + "18": "3PA", + "19": "FG%", + "20": "FT%", + "21": "3PT%", + "22": "AFG%", + "23": "FGMI", + "24": "FTMI", + "25": "3PMI", + "26": "APG", + "27": "BPG", + "28": "MPG", + "29": "PPG", + "30": "RPG", + "31": "SPG", + "32": "TOPG", + "33": "3PG", + "34": "PPM", + "35": "A/TO", + "36": "STR", + "37": "DD", + "38": "TD", + "39": "QD", + "40": "MIN", + "41": "GS", + "42": "GP", + "43": "TW", + "44": "FTR", + "45": "45", +} STAT_ID_MAP = { - '00': 'total', - '10': 'projected', - '01': 'last_7', - '02': 'last_15', - '03': 'last_30' + "00": "total", + "10": "projected", + "01": "last_7", + "02": "last_15", + "03": "last_30", } ACTIVITY_MAP = { - 178: 'FA ADDED', - 180: 'WAIVER ADDED', - 179: 'DROPPED', - 181: 'DROPPED', - 239: 'DROPPED', - 244: 'TRADED', - 'FA': 178, - 'WAIVER': 180, - 'TRADED': 244 + 178: "FA ADDED", + 180: "WAIVER ADDED", + 179: "DROPPED", + 181: "DROPPED", + 239: "DROPPED", + 244: "TRADED", + "FA": 178, + "WAIVER": 180, + "TRADED": 244, } -NINE_CAT_STATS = { - '3PTM', - 'AST', - 'BLK', - 'FG%', - 'FT%', - 'PTS', - 'REB', - 'STL', - 'TO' -} +NINE_CAT_STATS = {"3PTM", "AST", "BLK", "FG%", "FT%", "PTS", "REB", "STL", "TO"} From 5ee27165fb7c7a66486c71bfd1959ab7471d7d5a Mon Sep 17 00:00:00 2001 From: martincham Date: Fri, 6 Sep 2024 17:23:27 -0400 Subject: [PATCH 2/6] add category abbreviations --- espn_api/wbasketball/constant.py | 179 +++++++++++++++---------------- 1 file changed, 87 insertions(+), 92 deletions(-) diff --git a/espn_api/wbasketball/constant.py b/espn_api/wbasketball/constant.py index 3dab95a1..3c9cd636 100644 --- a/espn_api/wbasketball/constant.py +++ b/espn_api/wbasketball/constant.py @@ -1,104 +1,99 @@ POSITION_MAP = { - 0: '', - 1: 'G', - 2: 'F', - 3: 'C', - 4: 'F/C', - 5: 'UTIL', - 6: 'BE', - 7: 'IR', - 8: 'Unknown', - 9: 'Unknown', + 0: "", + 1: "G", + 2: "F", + 3: "C", + 4: "F/C", + 5: "UTIL", + 6: "BE", + 7: "IR", + 8: "Unknown", + 9: "Unknown", # reverse - 'G': 1, - 'F': 2, - 'C': 3, - 'F/C': 4, - 'UTIL': 5, - 'BE': 6, - 'IR': 7 + "G": 1, + "F": 2, + "C": 3, + "F/C": 4, + "UTIL": 5, + "BE": 6, + "IR": 7, } PRO_TEAM_MAP = { - 0: 'FA', - 3: 'Dal', - 5: 'Ind', - 6: 'LA', - 8: 'Min', - 9: 'NY', - 11: 'Phx', - 14: 'Sea', - 16: 'Wsh', - 17: 'LV', - 18: 'Conn', - 19: 'Chi', - 20: 'Atl', + 0: "FA", + 3: "Dal", + 5: "Ind", + 6: "LA", + 8: "Min", + 9: "NY", + 11: "Phx", + 14: "Sea", + 16: "Wsh", + 17: "LV", + 18: "Conn", + 19: "Chi", + 20: "Atl", } STATS_MAP = { - '0': 'PTS', - '1': 'BLK', - '2': 'STL', - '3': 'AST', - '4': 'OREB', - '5': 'DREB', - '6': 'REB', - '7': '', - '8': '', - '9': 'PF', - '10': '', - '11': 'TO', - '12': '', - '13': 'FGM', - '14': 'FGA', - '15': 'FTM', - '16': 'FTA', - '17': '3PTM', - '18': '3PTA', - '19': 'FG%', - '20': 'FT%', - '21': '3PT%', - '22': '', - '23': '', - '24': '', - '25': '', - '26': '', - '27': '', - '28': 'MPG', - '29': '', - '30': '', - '31': '', - '32': '', - '33': '', - '34': '', - '35': '', - '36': '', - '37': '', - '38': '', - '39': '', - '40': 'MIN', - '41': 'GS', - '42': 'GP', - '43': '', - '44': '', - '45': '', - } - -STAT_ID_MAP = { - '10': 'projected', - '01': 'last_7', - '02': 'last_15', - '03': 'last_30' + "0": "PTS", + "1": "BLK", + "2": "STL", + "3": "AST", + "4": "OREB", + "5": "DREB", + "6": "REB", + "7": "EJ", + "8": "FF", + "9": "PF", + "10": "TF", + "11": "TO", + "12": "DQ", + "13": "FGM", + "14": "FGA", + "15": "FTM", + "16": "FTA", + "17": "3PM", + "18": "3PA", + "19": "FG%", + "20": "FT%", + "21": "3PT%", + "22": "AFG%", + "23": "FGMI", + "24": "FTMI", + "25": "3PMI", + "26": "APG", + "27": "BPG", + "28": "MPG", + "29": "PPG", + "30": "RPG", + "31": "SPG", + "32": "TOPG", + "33": "3PG", + "34": "PPM", + "35": "A/TO", + "36": "STR", + "37": "DD", + "38": "TD", + "39": "QD", + "40": "MIN", + "41": "GS", + "42": "GP", + "43": "TW", + "44": "FTR", + "45": "45", } +STAT_ID_MAP = {"10": "projected", "01": "last_7", "02": "last_15", "03": "last_30"} + ACTIVITY_MAP = { - 178: 'FA ADDED', - 180: 'WAIVER ADDED', - 179: 'DROPPED', - 181: 'DROPPED', - 239: 'DROPPED', - 244: 'TRADED', - 'FA': 178, - 'WAIVER': 180, - 'TRADED': 244 + 178: "FA ADDED", + 180: "WAIVER ADDED", + 179: "DROPPED", + 181: "DROPPED", + 239: "DROPPED", + 244: "TRADED", + "FA": 178, + "WAIVER": 180, + "TRADED": 244, } From 0e3221fbcd5df933ef23b0b8c387545cd2f2f8ad Mon Sep 17 00:00:00 2001 From: martincham Date: Fri, 6 Sep 2024 17:27:50 -0400 Subject: [PATCH 3/6] update category name --- tests/basketball/integration/test_league.py | 52 ++++++++++++--------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/tests/basketball/integration/test_league.py b/tests/basketball/integration/test_league.py index 538ed5df..bfaf28bd 100644 --- a/tests/basketball/integration/test_league.py +++ b/tests/basketball/integration/test_league.py @@ -1,16 +1,16 @@ from unittest import TestCase from espn_api.basketball import League + # Integration test to make sure ESPN's API didn't change class LeagueTest(TestCase): def setUp(self): self.league = League(411647, 2019) def test_league_init(self): - self.assertEqual(self.league.scoringPeriodId, 178) player = self.league.teams[0].roster[0] - self.assertEqual(player.schedule['2']['team'], 'BKN') + self.assertEqual(player.schedule["2"]["team"], "BKN") self.assertEqual(player.total_points, 3583.0) self.assertEqual(player.avg_points, 45.35) @@ -23,43 +23,47 @@ def test_league_scoreboard(self): def test_league_draft(self): draft = self.league.draft - self.assertEqual(draft[1].playerName, 'LeBron James') + self.assertEqual(draft[1].playerName, "LeBron James") self.assertEqual(draft[1].round_num, 1) self.assertEqual(draft[2].round_pick, 3) - self.assertEqual(draft[2].team.team_name, 'Denver Nuggets ') + self.assertEqual(draft[2].team.team_name, "Denver Nuggets ") def test_league_free_agents(self): free_agents = self.league.free_agents() self.assertNotEqual(len(free_agents), 0) + def test_player_info(self): player_id = self.league.teams[0].roster[0].playerId player = self.league.player_info(playerId=player_id) - self.assertEqual(player.__repr__(), 'Player(Andre Drummond)') - self.assertEqual(player.schedule['2']['team'], 'BKN') - self.assertEqual(player.stats['2']['team'], 'BKN') - self.assertEqual(player.stats['2']['total']['PTS'], 24.0) - self.assertEqual(player.nine_cat_averages, + self.assertEqual(player.__repr__(), "Player(Andre Drummond)") + self.assertEqual(player.schedule["2"]["team"], "BKN") + self.assertEqual(player.stats["2"]["team"], "BKN") + self.assertEqual(player.stats["2"]["total"]["PTS"], 24.0) + self.assertEqual( + player.nine_cat_averages, { - 'PTS': 17.3, - 'BLK': 1.7, - 'STL': 1.7, - 'AST': 1.4, - 'REB': 15.6, - 'TO': 2.2, - '3PTM': 0.1, - 'FG%': 0.533, - 'FT%': 0.59 - } + "PTS": 17.3, + "BLK": 1.7, + "STL": 1.7, + "AST": 1.4, + "REB": 15.6, + "TO": 2.2, + "3PM": 0.1, + "FG%": 0.533, + "FT%": 0.59, + }, ) def test_league_box_scores(self): final_matchup = self.league.box_scores()[0] middle_matchup = self.league.box_scores(matchup_period=7)[0] # same matchup period but single scoring period - scoring_period_matchup = self.league.box_scores(scoring_period=48, matchup_total=False)[0] + scoring_period_matchup = self.league.box_scores( + scoring_period=48, matchup_total=False + )[0] self.assertEqual(final_matchup.home_score, 4240.0) self.assertEqual(final_matchup.away_lineup[0].points, 156.0) @@ -75,10 +79,12 @@ def test_league_box_scores_category(self): score = league.box_scores(matchup_period=3, scoring_period=21) - self.assertEqual(score[0].__repr__(), 'Box Score(Team(Team McWilliams) at Team(Team Wendt))') - self.assertEqual(score[0].away_lineup[0].name, 'Stephen Curry') + self.assertEqual( + score[0].__repr__(), "Box Score(Team(Team McWilliams) at Team(Team Wendt))" + ) + self.assertEqual(score[0].away_lineup[0].name, "Stephen Curry") # comment for now until matchup week is over - self.assertEqual(score[0].away_stats['PTS'], { 'value': 733.0, 'result': 'WIN' }) + self.assertEqual(score[0].away_stats["PTS"], {"value": 733.0, "result": "WIN"}) def test_past_league(self): league = League(411647, 2017) From bf3bbf4b415b2fc86c1981b6f1f37636aba35396 Mon Sep 17 00:00:00 2001 From: martincham Date: Fri, 6 Sep 2024 17:42:33 -0400 Subject: [PATCH 4/6] undo linting --- espn_api/basketball/constant.py | 256 ++++++++++---------- espn_api/wbasketball/constant.py | 177 +++++++------- tests/basketball/integration/test_league.py | 38 +-- 3 files changed, 243 insertions(+), 228 deletions(-) diff --git a/espn_api/basketball/constant.py b/espn_api/basketball/constant.py index 86d9f6d8..aa5c29ae 100644 --- a/espn_api/basketball/constant.py +++ b/espn_api/basketball/constant.py @@ -1,139 +1,149 @@ POSITION_MAP = { - 0: "PG", - 1: "SG", - 2: "SF", - 3: "PF", - 4: "C", - 5: "G", - 6: "F", - 7: "SG/SF", - 8: "G/F", - 9: "PF/C", - 10: "F/C", - 11: "UT", - 12: "BE", - 13: "IR", - 14: "", - 15: "Rookie", + 0: 'PG', + 1: 'SG', + 2: 'SF', + 3: 'PF', + 4: 'C', + 5: 'G', + 6: 'F', + 7: 'SG/SF', + 8: 'G/F', + 9: 'PF/C', + 10: 'F/C', + 11: 'UT', + 12: 'BE', + 13: 'IR', + 14: '', + 15: 'Rookie', # reverse - "PG": 0, - "SG": 1, - "SF": 2, - "PF": 3, - "C": 4, - "G": 5, - "F": 6, - "SG/SF": 7, - "G/F": 8, - "PF/C": 9, - "F/C": 10, - "UT": 11, - "BE": 12, - "IR": 13, - "Rookie": 15, + 'PG': 0, + 'SG': 1, + 'SF': 2, + 'PF': 3, + 'C': 4, + 'G': 5, + 'F': 6, + 'SG/SF': 7, + 'G/F': 8, + 'PF/C': 9, + 'F/C': 10, + 'UT': 11, + 'BE': 12, + 'IR': 13, + 'Rookie': 15, } PRO_TEAM_MAP = { - 0: "FA", - 1: "ATL", - 2: "BOS", - 3: "NOP", - 4: "CHI", - 5: "CLE", - 6: "DAL", - 7: "DEN", - 8: "DET", - 9: "GSW", - 10: "HOU", - 11: "IND", - 12: "LAC", - 13: "LAL", - 14: "MIA", - 15: "MIL", - 16: "MIN", - 17: "BKN", - 18: "NYK", - 19: "ORL", - 20: "PHL", - 21: "PHO", - 22: "POR", - 23: "SAC", - 24: "SAS", - 25: "OKC", - 26: "UTA", - 27: "WAS", - 28: "TOR", - 29: "MEM", - 30: "CHA", + 0: 'FA', + 1: 'ATL', + 2: 'BOS', + 3: 'NOP', + 4: 'CHI', + 5: 'CLE', + 6: 'DAL', + 7: 'DEN', + 8: 'DET', + 9: 'GSW', + 10: 'HOU', + 11: 'IND', + 12: 'LAC', + 13: 'LAL', + 14: 'MIA', + 15: 'MIL', + 16: 'MIN', + 17: 'BKN', + 18: 'NYK', + 19: 'ORL', + 20: 'PHL', + 21: 'PHO', + 22: 'POR', + 23: 'SAC', + 24: 'SAS', + 25: 'OKC', + 26: 'UTA', + 27: 'WAS', + 28: 'TOR', + 29: 'MEM', + 30: 'CHA', } STATS_MAP = { - "0": "PTS", - "1": "BLK", - "2": "STL", - "3": "AST", - "4": "OREB", - "5": "DREB", - "6": "REB", - "7": "EJ", - "8": "FF", - "9": "PF", - "10": "TF", - "11": "TO", - "12": "DQ", - "13": "FGM", - "14": "FGA", - "15": "FTM", - "16": "FTA", - "17": "3PM", - "18": "3PA", - "19": "FG%", - "20": "FT%", - "21": "3PT%", - "22": "AFG%", - "23": "FGMI", - "24": "FTMI", - "25": "3PMI", - "26": "APG", - "27": "BPG", - "28": "MPG", - "29": "PPG", - "30": "RPG", - "31": "SPG", - "32": "TOPG", - "33": "3PG", - "34": "PPM", - "35": "A/TO", - "36": "STR", - "37": "DD", - "38": "TD", - "39": "QD", - "40": "MIN", - "41": "GS", - "42": "GP", - "43": "TW", - "44": "FTR", - "45": "45", + '0': 'PTS', + '1': 'BLK', + '2': 'STL', + '3': 'AST', + '4': 'OREB', + '5': 'DREB', + '6': 'REB', + '7': 'EJ', + '8': 'FF', + '9': 'PF', + '10': 'TF', + '11': 'TO', + '12': 'DQ', + '13': 'FGM', + '14': 'FGA', + '15': 'FTM', + '16': 'FTA', + '17': '3PM', + '18': '3PA', + '19': 'FG%', + '20': 'FT%', + '21': '3PT%', + '22': 'AFG%', + '23': 'FGMI', + '24': 'FTMI', + '25': '3PMI', + '26': 'APG', + '27': 'BPG', + '28': 'MPG', + '29': 'PPG', + '30': 'RPG', + '31': 'SPG', + '32': 'TOPG', + '33': '3PG', + '34': 'PPM', + '35': 'A/TO', + '36': 'STR', + '37': 'DD', + '38': 'TD', + '39': 'QD', + '40': 'MIN', + '41': 'GS', + '42': 'GP', + '43': 'TW', + '44': 'FTR', + '45': '45', } STAT_ID_MAP = { - "00": "total", - "10": "projected", - "01": "last_7", - "02": "last_15", - "03": "last_30", + '00': 'total', + '10': 'projected', + '01': 'last_7', + '02': 'last_15', + '03': 'last_30', } ACTIVITY_MAP = { - 178: "FA ADDED", - 180: "WAIVER ADDED", - 179: "DROPPED", - 181: "DROPPED", - 239: "DROPPED", - 244: "TRADED", - "FA": 178, - "WAIVER": 180, - "TRADED": 244, + 178: 'FA ADDED', + 180: 'WAIVER ADDED', + 179: 'DROPPED', + 181: 'DROPPED', + 239: 'DROPPED', + 244: 'TRADED', + 'FA': 178, + 'WAIVER': 180, + 'TRADED': 244, } -NINE_CAT_STATS = {"3PTM", "AST", "BLK", "FG%", "FT%", "PTS", "REB", "STL", "TO"} +NINE_CAT_STATS = { + '3PTM', + 'AST', + 'BLK', + 'FG%', + 'FT%', + 'PTS', + 'REB', + 'STL', + 'TO', +} diff --git a/espn_api/wbasketball/constant.py b/espn_api/wbasketball/constant.py index 3c9cd636..bc77e6b7 100644 --- a/espn_api/wbasketball/constant.py +++ b/espn_api/wbasketball/constant.py @@ -1,99 +1,104 @@ POSITION_MAP = { - 0: "", - 1: "G", - 2: "F", - 3: "C", - 4: "F/C", - 5: "UTIL", - 6: "BE", - 7: "IR", - 8: "Unknown", - 9: "Unknown", + 0: '', + 1: 'G', + 2: 'F', + 3: 'C', + 4: 'F/C', + 5: 'UTIL', + 6: 'BE', + 7: 'IR', + 8: 'Unknown', + 9: 'Unknown', # reverse - "G": 1, - "F": 2, - "C": 3, - "F/C": 4, - "UTIL": 5, - "BE": 6, - "IR": 7, + 'G': 1, + 'F': 2, + 'C': 3, + 'F/C': 4, + 'UTIL': 5, + 'BE': 6, + 'IR': 7, } PRO_TEAM_MAP = { - 0: "FA", - 3: "Dal", - 5: "Ind", - 6: "LA", - 8: "Min", - 9: "NY", - 11: "Phx", - 14: "Sea", - 16: "Wsh", - 17: "LV", - 18: "Conn", - 19: "Chi", - 20: "Atl", + 0: 'FA', + 3: 'Dal', + 5: 'Ind', + 6: 'LA', + 8: 'Min', + 9: 'NY', + 11: 'Phx', + 14: 'Sea', + 16: 'Wsh', + 17: 'LV', + 18: 'Conn', + 19: 'Chi', + 20: 'Atl', } STATS_MAP = { - "0": "PTS", - "1": "BLK", - "2": "STL", - "3": "AST", - "4": "OREB", - "5": "DREB", - "6": "REB", - "7": "EJ", - "8": "FF", - "9": "PF", - "10": "TF", - "11": "TO", - "12": "DQ", - "13": "FGM", - "14": "FGA", - "15": "FTM", - "16": "FTA", - "17": "3PM", - "18": "3PA", - "19": "FG%", - "20": "FT%", - "21": "3PT%", - "22": "AFG%", - "23": "FGMI", - "24": "FTMI", - "25": "3PMI", - "26": "APG", - "27": "BPG", - "28": "MPG", - "29": "PPG", - "30": "RPG", - "31": "SPG", - "32": "TOPG", - "33": "3PG", - "34": "PPM", - "35": "A/TO", - "36": "STR", - "37": "DD", - "38": "TD", - "39": "QD", - "40": "MIN", - "41": "GS", - "42": "GP", - "43": "TW", - "44": "FTR", - "45": "45", + '0': 'PTS', + '1': 'BLK', + '2': 'STL', + '3': 'AST', + '4': 'OREB', + '5': 'DREB', + '6': 'REB', + '7': 'EJ', + '8': 'FF', + '9': 'PF', + '10': 'TF', + '11': 'TO', + '12': 'DQ', + '13': 'FGM', + '14': 'FGA', + '15': 'FTM', + '16': 'FTA', + '17': '3PM', + '18': '3PA', + '19': 'FG%', + '20': 'FT%', + '21': '3PT%', + '22': 'AFG%', + '23': 'FGMI', + '24': 'FTMI', + '25': '3PMI', + '26': 'APG', + '27': 'BPG', + '28': 'MPG', + '29': 'PPG', + '30': 'RPG', + '31': 'SPG', + '32': 'TOPG', + '33': '3PG', + '34': 'PPM', + '35': 'A/TO', + '36': 'STR', + '37': 'DD', + '38': 'TD', + '39': 'QD', + '40': 'MIN', + '41': 'GS', + '42': 'GP', + '43': 'TW', + '44': 'FTR', + '45': '45', } -STAT_ID_MAP = {"10": "projected", "01": "last_7", "02": "last_15", "03": "last_30"} +STAT_ID_MAP = { + '10': 'projected', + '01': 'last_7', + '02': 'last_15', + '03': 'last_30' +} ACTIVITY_MAP = { - 178: "FA ADDED", - 180: "WAIVER ADDED", - 179: "DROPPED", - 181: "DROPPED", - 239: "DROPPED", - 244: "TRADED", - "FA": 178, - "WAIVER": 180, - "TRADED": 244, + 178: 'FA ADDED', + 180: 'WAIVER ADDED', + 179: 'DROPPED', + 181: 'DROPPED', + 239: 'DROPPED', + 244: 'TRADED', + 'FA': 178, + 'WAIVER': 180, + 'TRADED': 244, } diff --git a/tests/basketball/integration/test_league.py b/tests/basketball/integration/test_league.py index bfaf28bd..bf3d7ea9 100644 --- a/tests/basketball/integration/test_league.py +++ b/tests/basketball/integration/test_league.py @@ -10,7 +10,7 @@ def setUp(self): def test_league_init(self): self.assertEqual(self.league.scoringPeriodId, 178) player = self.league.teams[0].roster[0] - self.assertEqual(player.schedule["2"]["team"], "BKN") + self.assertEqual(player.schedule['2']['team'], 'BKN') self.assertEqual(player.total_points, 3583.0) self.assertEqual(player.avg_points, 45.35) @@ -23,10 +23,10 @@ def test_league_scoreboard(self): def test_league_draft(self): draft = self.league.draft - self.assertEqual(draft[1].playerName, "LeBron James") + self.assertEqual(draft[1].playerName, 'LeBron James') self.assertEqual(draft[1].round_num, 1) self.assertEqual(draft[2].round_pick, 3) - self.assertEqual(draft[2].team.team_name, "Denver Nuggets ") + self.assertEqual(draft[2].team.team_name, 'Denver Nuggets ') def test_league_free_agents(self): free_agents = self.league.free_agents() @@ -38,22 +38,22 @@ def test_player_info(self): player = self.league.player_info(playerId=player_id) - self.assertEqual(player.__repr__(), "Player(Andre Drummond)") - self.assertEqual(player.schedule["2"]["team"], "BKN") - self.assertEqual(player.stats["2"]["team"], "BKN") - self.assertEqual(player.stats["2"]["total"]["PTS"], 24.0) + self.assertEqual(player.__repr__(), 'Player(Andre Drummond)') + self.assertEqual(player.schedule['2']['team'], 'BKN') + self.assertEqual(player.stats['2']['team'], 'BKN') + self.assertEqual(player.stats['2']['total']['PTS'], 24.0) self.assertEqual( player.nine_cat_averages, { - "PTS": 17.3, - "BLK": 1.7, - "STL": 1.7, - "AST": 1.4, - "REB": 15.6, - "TO": 2.2, - "3PM": 0.1, - "FG%": 0.533, - "FT%": 0.59, + 'PTS': 17.3, + 'BLK': 1.7, + 'STL': 1.7, + 'AST': 1.4, + 'REB': 15.6, + 'TO': 2.2, + '3PM': 0.1, + 'FG%': 0.533, + 'FT%': 0.59, }, ) @@ -80,11 +80,11 @@ def test_league_box_scores_category(self): score = league.box_scores(matchup_period=3, scoring_period=21) self.assertEqual( - score[0].__repr__(), "Box Score(Team(Team McWilliams) at Team(Team Wendt))" + score[0].__repr__(), 'Box Score(Team(Team McWilliams) at Team(Team Wendt))' ) - self.assertEqual(score[0].away_lineup[0].name, "Stephen Curry") + self.assertEqual(score[0].away_lineup[0].name, 'Stephen Curry') # comment for now until matchup week is over - self.assertEqual(score[0].away_stats["PTS"], {"value": 733.0, "result": "WIN"}) + self.assertEqual(score[0].away_stats['PTS'], {'value': 733.0, 'result': 'WIN'}) def test_past_league(self): league = League(411647, 2017) From 1f29fa9a7f3ba02c66586b4822dd73187252e352 Mon Sep 17 00:00:00 2001 From: martincham Date: Fri, 6 Sep 2024 17:49:49 -0400 Subject: [PATCH 5/6] remove more linting --- espn_api/basketball/constant.py | 16 ++++++++-------- espn_api/wbasketball/constant.py | 8 ++++---- tests/basketball/integration/test_league.py | 13 ++++--------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/espn_api/basketball/constant.py b/espn_api/basketball/constant.py index aa5c29ae..9a6196d5 100644 --- a/espn_api/basketball/constant.py +++ b/espn_api/basketball/constant.py @@ -137,13 +137,13 @@ } NINE_CAT_STATS = { - '3PTM', - 'AST', - 'BLK', - 'FG%', - 'FT%', - 'PTS', - 'REB', - 'STL', + '3PTM', + 'AST', + 'BLK', + 'FG%', + 'FT%', + 'PTS', + 'REB', + 'STL', 'TO', } diff --git a/espn_api/wbasketball/constant.py b/espn_api/wbasketball/constant.py index bc77e6b7..7fb301a4 100644 --- a/espn_api/wbasketball/constant.py +++ b/espn_api/wbasketball/constant.py @@ -85,10 +85,10 @@ } STAT_ID_MAP = { - '10': 'projected', - '01': 'last_7', - '02': 'last_15', - '03': 'last_30' + '10': 'projected', + '01': 'last_7', + '02': 'last_15', + '03': 'last_30', } ACTIVITY_MAP = { diff --git a/tests/basketball/integration/test_league.py b/tests/basketball/integration/test_league.py index bf3d7ea9..a2f79cc3 100644 --- a/tests/basketball/integration/test_league.py +++ b/tests/basketball/integration/test_league.py @@ -42,8 +42,7 @@ def test_player_info(self): self.assertEqual(player.schedule['2']['team'], 'BKN') self.assertEqual(player.stats['2']['team'], 'BKN') self.assertEqual(player.stats['2']['total']['PTS'], 24.0) - self.assertEqual( - player.nine_cat_averages, + self.assertEqual(player.nine_cat_averages, { 'PTS': 17.3, 'BLK': 1.7, @@ -61,9 +60,7 @@ def test_league_box_scores(self): final_matchup = self.league.box_scores()[0] middle_matchup = self.league.box_scores(matchup_period=7)[0] # same matchup period but single scoring period - scoring_period_matchup = self.league.box_scores( - scoring_period=48, matchup_total=False - )[0] + scoring_period_matchup = self.league.box_scores(scoring_period=48, matchup_total=False)[0] self.assertEqual(final_matchup.home_score, 4240.0) self.assertEqual(final_matchup.away_lineup[0].points, 156.0) @@ -79,12 +76,10 @@ def test_league_box_scores_category(self): score = league.box_scores(matchup_period=3, scoring_period=21) - self.assertEqual( - score[0].__repr__(), 'Box Score(Team(Team McWilliams) at Team(Team Wendt))' - ) + self.assertEqual(score[0].__repr__(), 'Box Score(Team(Team McWilliams) at Team(Team Wendt))') self.assertEqual(score[0].away_lineup[0].name, 'Stephen Curry') # comment for now until matchup week is over - self.assertEqual(score[0].away_stats['PTS'], {'value': 733.0, 'result': 'WIN'}) + self.assertEqual(score[0].away_stats['PTS'], { 'value': 733.0, 'result': 'WIN' }) def test_past_league(self): league = League(411647, 2017) From 99a4906631cb9e4f63b234e84d970b24ed57796b Mon Sep 17 00:00:00 2001 From: martincham Date: Mon, 9 Sep 2024 13:41:37 -0400 Subject: [PATCH 6/6] fix NINE_CAT_STATS --- espn_api/basketball/constant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espn_api/basketball/constant.py b/espn_api/basketball/constant.py index 9a6196d5..e5c8c823 100644 --- a/espn_api/basketball/constant.py +++ b/espn_api/basketball/constant.py @@ -137,7 +137,7 @@ } NINE_CAT_STATS = { - '3PTM', + '3PM', 'AST', 'BLK', 'FG%',