spilchen / yahoo_fantasy_api

python bindings for the Yahoo! Fantasy API (https://yahoo-fantasy-api.readthedocs.io/)
MIT License
93 stars 34 forks source link

position_type KeyError #30

Open ryanlaughlin opened 2 years ago

ryanlaughlin commented 2 years ago

I just ran a script for the first time in six months and I'm getting this error whenever calling roster

~/anaconda3/lib/python3.8/site-packages/yahoo_fantasy_api/team.py in roster(self, week, day)
     93                     plyr["position_type"] = next_item["position_type"]
     94                 else:
---> 95                     plyr["position_type"] = next(it)["position_type"]
     96                 plyr["eligible_positions"] = _compact_eligible_pos(next(it))
     97                 plyr["selected_position"] = _compact_selected_pos(next(it))

KeyError: 'position_type'
DMcP89 commented 2 years ago

@ryanlaughlin can you post the script you are running or provide a link to it?

gitJDJ commented 2 years ago

I ran into this same issue trying to get rosters from a fantasy football league. I discovered that the objectpath filter was pulling a {status: False} for each player in addition to a player's status on injury, suspension, etc.

I resolved the issue by redefining the 'it' variable after Lines 71-73 as follows: it = iter([item for item in it if item != {'status': False}])

gitJDJ commented 2 years ago

I ran into this same issue trying to get rosters from a fantasy football league. I discovered that the objectpath filter was pulling a {status: False} for each player in addition to a player's status on injury, suspension, etc.

I resolved the issue by redefining the 'it' variable after Lines 71-73 as follows: it = iter([item for item in it if item != {'status': False}])

Ah, now that I cloned the repo I see this was only a problem in my original installation and has since been resolved. Thanks!