fix: resolve get_normalized_dict() returning empty for V3 endpoints#606
fix: resolve get_normalized_dict() returning empty for V3 endpoints#606brandonhawi wants to merge 2 commits intoswar:masterfrom
Conversation
Add support for V3 endpoints with custom parsers in get_normalized_dict() and get_normalized_json() methods. Previously, these methods only handled legacy format (resultSets/resultSet) and returned empty dictionaries for V3 endpoints like BoxScoreTraditionalV3. Changes: - Store endpoint name in NBAStatsResponse when get_data_sets() is called - Update get_normalized_dict() to use parser for V3 endpoints - Convert parsed V3 data to normalized format (list of dicts) - Add comprehensive unit tests for normalized methods Fixes swar#602
Remove all inline comments and docstrings from the V3 endpoint normalization implementation and associated unit tests to improve code readability and reduce clutter.
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self._endpoint = None | ||
|
|
There was a problem hiding this comment.
What's the intention behind self._endpoint?
There was a problem hiding this comment.
self._endpoint stores the endpoint name from get_data_sets(endpoint="...") so that get_normalized_dict() knows which V3 parser to use.
Without it, get_normalized_dict() only has access to the raw response data (via self.get_dict()), which doesn't contain the endpoint name needed to select the correct parser.
Set to None by default, so legacy endpoints continue working unchanged.
|
Overall this code seems fine. We'll just want test it out and ensure it's working. I do have a comment in the code as I'm trying to understand the need for adding |
|
Tests are included in the PR. Happy to add more if you have specific scenarios in mind! |
|
Hey Brandon - I am going to keep this open until the next release. I want to run through some tests before I actually merge this in. |
Summary
Fixes #602
This PR resolves the issue where
get_normailized*methods return empty values.Notebook Demonstrating Fix
Root Cause:
Solution
Added V3 endpoint support to the normalization pipeline in src/nba_api/stats/library/http.py:
context for normalization
keys)
endpoint is stored
Testing
Created new unit tests and all existing tests pass.