Bills.py on ids s1696-113 and sjres10-113 has TypeError Exception
joec58 opened this issue · 3 comments
Lines 159 and 160 in bills.py have an error.
'by_request': bill_dict['sponsors']['item'][0]['byRequestType'] is not None,
results in TypeError: 'NoneType' object has no attribute '__getitem__'
when bill_dict['sponsors'] = None
. Not correctly handling bill_dict['sponsors'] = None
will also cause line 160 to exception.
The corrected lines would be
[line 159:] 'by_request': bill_dict['sponsors']['item'][0]['byRequestType'] if bill_dict['sponsors'] else None,
and
[line 160:] 'sponsor': bill_info.sponsor_for(bill_dict['sponsors']['item'][0]) if bill_dict['sponsors'] else None,
.
These are the same form as used in line 179.
I think this may be due to GPO publishing invalid files for a little while: usgpo/bill-status#134
I think the data files are updated now though, since I'm not seeing this problem.
My suggested correction for line 159 would not work because by_request
requires a boolean value. I changed the code I use to ...
[line 159:] 'by_request': bill_dict['sponsors'] and (bill_dict['sponsors']['item'][0]['byRequestType'] is not None),
This is fixed now.