La variable de Python no es ninguna
if val is not None:
# ...
feddynventor
if val is not None:
# ...