pyinat/pyinaturalist

pprint cannot handle field with value None

Cewein opened this issue · 2 comments

The problem

import pyinaturalist as ina
responce =  ina.get_observations(lat=-33.34958863458624,lng=151.35598014660647,radius=530,per_page=100)

obs = ina.Observation.from_json_list(responce)
ina.pprint(obs)

lead to :

AttributeError: 'NoneType' object has no attribute 'id

Expected behavior

It should output a pretty print of the observation but since some observation had some area filled with None values it led to a crash.

Workarounds

a simple check could do the case put i simply remove the observation where 'taxon=None'.

Environment

  • OS & version: Lunix mint
  • Python version: 3.9
  • Pyinaturalist version or branch: main

Thanks for the bug report, I'll get that fixed.

This is fixed in main, and will be included in the next release.