Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BoxScoreTraditionalV3 API Bug(some game stats starters and bench is None, cause 'NoneType' object has no attribute 'values') #458

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

XatMassacrE
Copy link
Contributor

For example:
endpoint is : boxscoretraditionalv3
Game 0012300001, period 4, params is:

  params = {
    'game_id': '0012300001',
    'range_type': 1,
    'start_period': 4,
    'end_period': 4,
  }

NBA official Website response is like this(starters and bench is null):
image

but nba_api will throw an error:

  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/endpoints/boxscoretraditionalv3.py", line 141, in __init__
    self.get_request()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/endpoints/boxscoretraditionalv3.py", line 151, in get_request
    self.load_response()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/endpoints/boxscoretraditionalv3.py", line 154, in load_response
    data_sets = self.nba_response.get_data_sets(self.endpoint)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/library/http.py", line 150, in get_data_sets
    return endpoint_parser.get_data_sets()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/library/parserv3.py", line 234, in get_data_sets
    start_bench_data = self.get_start_bench_data()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/nba_api/stats/library/parserv3.py", line 145, in get_start_bench_data
    x for x in raw_dict["homeTeam"]["starters"].values()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'values'

@rsforbes rsforbes merged commit f1a19a4 into swar:master Aug 27, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants