I am calling a Monday.com board using their API and attempting to parse the returned JSON. I'm trying to check the value of a column in an item (row if you think of Monday as a table). My query works, I am getting the right data back I'm just stuck at filtering out NoneType class values.
Here is my code for checking NoneType values:
#column-data
lstCols = thisItem["column_values"]
for thisCol in lstCols:
if thisCol["column"]["title"] == "Core Eng (Pts)" and type(thisCol["value"]) is not None:
print(f'{cm.OKGREEN}{thisCol["column"]["title"]}{cm.ENDC}')
print(f'{cm.OKGREEN}{thisCol["value"]}{cm.ENDC}')
print(f'{cm.OKGREEN}{type(thisCol["value"])}{cm.ENDC}')
else:
print(f'{cm.WARNING}{thisCol["column"]["title"]}{cm.ENDC}')
break
I know for the Core Eng (Pts) column, it's value has a class of NoneType:
Core Eng (Pts)
None
<class 'NoneType'>
This is the output from the if condition above where the condition is being met. My expectation was that checking these values would not meet the if condition and jump to the else. I was referencing this Stackoverflow:
How to "test" NoneType in python?
and:
https://peps.python.org/pep-0008/#programming-recommendations
which states to check singletons such as None to use is and is not.
I'm not sure where I am going wrong on this.