yahoo_fantasy_api icon indicating copy to clipboard operation
yahoo_fantasy_api copied to clipboard

position_type KeyError

Open ryanlaughlin opened this issue 3 years ago • 3 comments

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'

ryanlaughlin avatar Aug 13 '22 18:08 ryanlaughlin

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

DMcP89 avatar Aug 25 '22 16:08 DMcP89

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 avatar Sep 08 '22 18:09 gitJDJ

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!

gitJDJ avatar Sep 08 '22 18:09 gitJDJ