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

Attribute Error #6

Closed
chisox721 opened this issue May 7, 2019 · 4 comments
Closed

Attribute Error #6

chisox721 opened this issue May 7, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@chisox721
Copy link

This could be an issue on my end but figured I would mention it just in case. When looping through dates my code will stop with an error like this:

line 145, in schedule 'away_pitcher_note': game['teams']['away'].get('probablePitcher').get('note',''),
AttributeError: 'NoneType' object has no attribute 'get'

This only happens with certain dates and after testing it seems to be pretty random. Here is what my code looks like (changing end_date to 03/23/2019 will return an error for me).

for x in statsapi.schedule(start_date='03/20/2019',end_date='03/21/2019'):
    if (x['status'] in ['Final','Game Over'] and x['game_type'] in ['R']):
        print(x['game_id'])
    else:
        pass
toddrob99 added a commit that referenced this issue May 8, 2019
@toddrob99
Copy link
Owner

This is due to my failure to account for a game with no probable pitcher listed when pulling pitcher reports. I did account for this when pulling the probable pitcher's name, but not the note. Specifically, gamePk=573193 on 3/23/19 did not have a probable pitcher listed for Canada Jr. Team (exhibition game, obviously). I have checked in the fix for v0.0.8. Thank you!

@toddrob99 toddrob99 self-assigned this May 8, 2019
@toddrob99 toddrob99 added the bug Something isn't working label May 8, 2019
@toddrob99
Copy link
Owner

>>> import statsapi
>>> statsapi.__version__
'0.0.8'
>>> for x in statsapi.schedule(start_date='03/20/2019',end_date='03/23/2019'):
...     if (x['status'] in ['Final','Game Over'] and x['game_type'] in ['R']):
...         print(x['game_id'])
...     else:
...         pass
...
566083
566084

@toddrob99 toddrob99 mentioned this issue May 8, 2019
toddrob99 added a commit that referenced this issue May 8, 2019
## v0.0.8
* FIX: Error in schedule() when probable pitcher is missing #6 
* FIX: Error in schedule() when linescore is missing (postponed games) #7
@toddrob99
Copy link
Owner

Please update to v0.0.8 with pip install --upgrade MLB-StatsAPI

@chisox721
Copy link
Author

Just ran a few tests and looked good. Thanks for the quick update on this Todd!

@skellet0r skellet0r mentioned this issue Oct 5, 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

No branches or pull requests

2 participants