r1chardj0n3s / parse

Parse strings using a specification based on the Python format() syntax.
http://pypi.python.org/pypi/parse
MIT License
1.72k stars 101 forks source link

FixedTzOffset.__eq__(...) Fails when other is None #92

Closed CraigMiloRogers closed 4 years ago

CraigMiloRogers commented 4 years ago

In parse 1.12.0 and 1.12.1, FixedTzOffset.eq(...) fails when other is None. matplotlib triggers this behavior (see https://github.com/matplotlib/matplotlib/issues/15924). The matplotlib maintainer asserts that parse.py should return False in this case.

CraigMiloRogers commented 4 years ago

Here is a proposed change to 'parse.py':

    def __eq__(self, other):
        if other is None:
            return False
        return self._name == other._name and self._offset == other._offset
CraigMiloRogers commented 4 years ago

However, there may be a style preference in the Python community for forcing the caller to protect against the None case (this is not quite the same situation as PEP 8 addresses).