wolfhong / LunarCalendar

A lunar calendar converter in Python, including 24 solar terms and a number of solar holidays and lunar holidays, mainly from China.
https://pypi.org/project/LunarCalendar/
MIT License
58 stars 17 forks source link

Fix incorrect usages of NotImplemented #12

Open brittanyrey opened 2 months ago

brittanyrey commented 2 months ago

This is an incorrect usage of NotImplemented. NotImplemented is a built-in constant used for binary special methods to indicate that there is not a implemented manner to handle a specific type. (see docs)

Essentially if you were to try a.__add__(b), hitting a NonImplemented would allow for a try of b.__add__(a).

Attempting to raise NotImplemented doesn't make sense as it is not an exception. NotImplementedError can be used instead

Example from repl:

>>> raise NotImplemented
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must derive from BaseException
>>> raise NotImplementedError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError