Skip to content

Commit 8304148

Browse files
committed
refactor: Refactor V3 parsers to dedicated _parsers module with comprehensive test coverage
Reorganize V3 boxscore parsers into a dedicated `_parsers/` module following separation of concerns and improving maintainability. All parsers now follow a consistent pattern with comprehensive test coverage using TDD approach. Changes: - Move existing parsers (boxscoreadvancedv3, boxscoretraditionalv3) to _parsers/ - Add 6 new parsers with complete implementations: - boxscoredefensivev2: Defensive statistics (deflections, charges, etc.) - boxscorefourfactorsv3: Four factors analysis (eFG%, TO%, etc.) - boxscorehustlev2: Hustle stats (contested shots, loose balls, etc.) - boxscoremiscv3: Miscellaneous stats (points off turnovers, etc.) - boxscoreplayertrackv3: Player tracking (distance, speed, touches, etc.) - boxscorescoringv3: Scoring breakdowns (2PT, 3PT, paint, etc.) - boxscoreusagev3: Usage percentages and possession distribution - Create parser registry in _parsers/__init__.py with register_parser() function - Fix circular import in http.py using lazy parser loading - Add 7 test suites with 86 comprehensive unit tests (all passing) - Add Python test fixtures (not JSON files) for all parsers - Add API response documentation in docs/nba_api/stats/endpoints/responses/ All parsers: - Return headers as lists (not tuples) for API compatibility - Follow consistent metadata patterns (team, player, statistics) - Handle missing/incomplete data gracefully - Include comprehensive test coverage (initialization, headers, data extraction) Test results: 329 total unit tests passing (86 new parser tests) Code quality: All files formatted with black/isort, linted with flake8
1 parent aed2f96 commit 8304148

36 files changed

+10490
-1094
lines changed

docs/nba_api/stats/endpoints/responses/boxscoreadvancedv3.json

Lines changed: 922 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscoredefensivev2.json

Lines changed: 657 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscorefourfactorsv3.json

Lines changed: 556 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscorehustlev2.json

Lines changed: 793 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscoremiscv3.json

Lines changed: 735 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscoreplayertrackv3.json

Lines changed: 965 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscorescoringv3.json

Lines changed: 738 additions & 0 deletions
Large diffs are not rendered by default.

docs/nba_api/stats/endpoints/responses/boxscoreusagev3.json

Lines changed: 847 additions & 0 deletions
Large diffs are not rendered by default.

src/nba_api/stats/endpoints/_parsers/__init__.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
- Returning data in the format expected by Endpoint.DataSet
1111
"""
1212

13-
from .boxscoreadvancedv3 import NBAStatsBoxscoreParserV3
13+
from .boxscoreadvancedv3 import NBAStatsBoxscoreAdvancedV3Parser
14+
from .boxscoredefensivev2 import NBAStatsBoxscoreDefensiveV2Parser
15+
from .boxscorefourfactorsv3 import NBAStatsBoxscoreFourFactorsV3Parser
16+
from .boxscorehustlev2 import NBAStatsBoxscoreHustleV2Parser
1417
from .boxscorematchupsv3 import NBAStatsBoxscoreMatchupsParserV3
18+
from .boxscoremiscv3 import NBAStatsBoxscoreMiscV3Parser
19+
from .boxscoreplayertrackv3 import NBAStatsBoxscorePlayerTrackV3Parser
20+
from .boxscorescoringv3 import NBAStatsBoxscoreScoringV3Parser
1521
from .boxscoresummaryv3 import NBAStatsBoxscoreSummaryParserV3
1622
from .boxscoretraditionalv3 import NBAStatsBoxscoreTraditionalParserV3
23+
from .boxscoreusagev3 import NBAStatsBoxscoreUsageV3Parser
1724
from .iststandings import NBAStatsISTStandingsParser
1825
from .playbyplayv3 import NBAStatsPlayByPlayParserV3
1926
from .scheduleleaguev2 import (
@@ -22,12 +29,19 @@
2229
)
2330

2431
__all__ = [
25-
"NBAStatsBoxscoreParserV3",
26-
"NBAStatsBoxscoreTraditionalParserV3",
32+
"NBAStatsBoxscoreAdvancedV3Parser",
33+
"NBAStatsBoxscoreDefensiveV2Parser",
34+
"NBAStatsBoxscoreFourFactorsV3Parser",
35+
"NBAStatsBoxscoreHustleV2Parser",
2736
"NBAStatsBoxscoreMatchupsParserV3",
37+
"NBAStatsBoxscoreMiscV3Parser",
38+
"NBAStatsBoxscorePlayerTrackV3Parser",
39+
"NBAStatsBoxscoreScoringV3Parser",
2840
"NBAStatsBoxscoreSummaryParserV3",
29-
"NBAStatsPlayByPlayParserV3",
41+
"NBAStatsBoxscoreTraditionalParserV3",
42+
"NBAStatsBoxscoreUsageV3Parser",
3043
"NBAStatsISTStandingsParser",
44+
"NBAStatsPlayByPlayParserV3",
3145
"NBAStatsScheduleLeagueV2Parser",
3246
"NBAStatsScheduleLeagueV2IntParser",
3347
"get_parser_for_endpoint",
@@ -36,17 +50,17 @@
3650

3751
# Mapping of endpoint names to their parser classes
3852
_PARSER_REGISTRY = {
39-
"boxscoreadvancedv3": NBAStatsBoxscoreParserV3,
40-
"boxscoredefensivev2": NBAStatsBoxscoreParserV3,
41-
"boxscorefourfactorsv3": NBAStatsBoxscoreParserV3,
42-
"boxscorehustlev2": NBAStatsBoxscoreParserV3,
53+
"boxscoreadvancedv3": NBAStatsBoxscoreAdvancedV3Parser,
54+
"boxscoredefensivev2": NBAStatsBoxscoreDefensiveV2Parser,
55+
"boxscorefourfactorsv3": NBAStatsBoxscoreFourFactorsV3Parser,
56+
"boxscorehustlev2": NBAStatsBoxscoreHustleV2Parser,
4357
"boxscorematchupsv3": NBAStatsBoxscoreMatchupsParserV3,
44-
"boxscoremiscv3": NBAStatsBoxscoreParserV3,
45-
"boxscoreplayertrackv3": NBAStatsBoxscoreParserV3,
46-
"boxscorescoringv3": NBAStatsBoxscoreParserV3,
58+
"boxscoremiscv3": NBAStatsBoxscoreMiscV3Parser,
59+
"boxscoreplayertrackv3": NBAStatsBoxscorePlayerTrackV3Parser,
60+
"boxscorescoringv3": NBAStatsBoxscoreScoringV3Parser,
4761
"boxscoresummaryv3": NBAStatsBoxscoreSummaryParserV3,
4862
"boxscoretraditionalv3": NBAStatsBoxscoreTraditionalParserV3,
49-
"boxscoreusagev3": NBAStatsBoxscoreParserV3,
63+
"boxscoreusagev3": NBAStatsBoxscoreUsageV3Parser,
5064
"playbyplayv3": NBAStatsPlayByPlayParserV3,
5165
"iststandings": NBAStatsISTStandingsParser,
5266
"scheduleleaguev2": NBAStatsScheduleLeagueV2Parser,

0 commit comments

Comments
 (0)