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

NBA players with empty stats pages throwing errors #217

Closed
roclark opened this issue Oct 4, 2019 · 0 comments · Fixed by #218
Closed

NBA players with empty stats pages throwing errors #217

roclark opened this issue Oct 4, 2019 · 0 comments · Fixed by #218
Assignees
Labels
bug Something isn't working
Milestone

Comments

@roclark
Copy link
Owner

roclark commented Oct 4, 2019

Describe the bug
Some players don't have a personal stats page created for them yet, but contain a valid link on roster pages, such as Moses Brown for the Portland Trail Blazers. As implemented, the Roster module for the NBA does not check if the returned data from the page is empty, and will attempt to parse information from an object which is None. Instead, if a player's page is invalid, the module should fail-fast and return None for the player instead of attempting to parse information or handle other scenarios.

To Reproduce
Querying the Portland Trail Blazer's roster, especially Moses Brown's personal stats page, will throw an error.

from sportsreference.nba.roster import Roster

roster = Roster('POR')
for player in roster.players:
    print(player.name)

Expected behavior
Any player which has an invalid page should have None returned for their information instead of throwing an error.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04 (affects all)
  • Sportsreference Version: 0.4.5

Additional context
Traceback:

Traceback (most recent call last):
  File "tests/exhaustive/test_nba.py", line 7, in <module>
    for player in team.roster.players:
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/teams.py", line 209, in roster
    return Roster(self._abbreviation, self._year)
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/roster.py", line 1199, in __init__
    self._find_players(year)
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/roster.py", line 1323, in _find_players
    player_instance = Player(player_id)
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/roster.py", line 170, in __init__
    player_data = self._pull_player_data()
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/roster.py", line 487, in _pull_player_data
    self._parse_player_information(player_info)
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/nba/roster.py", line 348, in _parse_player_information
    value = utils._parse_field(PLAYER_SCHEME, player_info, short_field)
  File "/home/runner/work/sportsreference/sportsreference/sportsreference/utils.py", line 190, in _parse_field
    items = [i.text() for i in html_data(scheme).items()]
@roclark roclark added the bug Something isn't working label Oct 4, 2019
@roclark roclark added this to the Release 0.5.0 milestone Oct 4, 2019
@roclark roclark self-assigned this Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant