Since return_ranked_list is initiallized to False, calling int(return_ranked_list=False) will set num_to_return to 0, throwing an error when calling alls[0]['structure'], since when return_ranked_list==0, alls is a structure object. Thus include else flag incase num_to_return is 0
Merge branch 'master' of github.com:materialsproject/pymatgen