majiidd / persiantools

Jalali date and datetime with other tools
MIT License
166 stars 20 forks source link

Fix comparisons == and != to always return a bool. #18

Closed hramezani closed 2 years ago

hramezani commented 2 years ago

It is mentioned in python official datetime doc

The comparisons == or != always return a bool, no matter the type of the compared object

Here are comparisons in datetime:

>>> from datetime import date
>>> date.today() == ''
False
>>> date.today() != ''
True

But in this package we will get:

>>> from persiantools.jdatetime import JalaliDate
>>> JalaliDate.today() == ''
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../lib/python3.9/site-packages/persiantools/jdatetime.py", line 500, in __eq__
    raise NotImplementedError
NotImplementedError