This problem also comes up when migrating to Python 3.
In Python 2 comparing an integer to None will “work,” such that None is considered less than any integer, even negative ones:
>>> None > 1
False
>>> None < 1
True
In Python 3 such comparisons raise a TypeError:
>>> None > 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '>' not supported between instances of 'NoneType' and 'int'
>>> None < 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: '<' not supported between instances of 'NoneType' and 'int'