Skip to content

Conversation

@mobinghoveoud
Copy link
Contributor

fix #163

Description of Changes

The __ne__ function in jdatetime.datetime was implemented using __eq__ (return not self.__eq__(other_datetime)), ensuring proper handling of comparisons with datetime.datetime. This fix correctly returns True for unequal types, and tests were added to validate the behavior.

If there are any issues or areas for improvement, please feel free to let me know.
Thanks.

@mobinghoveoud
Copy link
Contributor Author

Can this be released with v5.1.1?

@5j9
Copy link
Contributor

5j9 commented Jan 23, 2025

Suggestion: There are two definitions of __ne__, one for date and one for datetime class. They are buggy; removing both should resolve the issues. (Python's default behavior is to fall back to __eq__ when __ne__ is not defined.) This approach will reduce code duplication and prevent future errors, in my opinion.

@mobinghoveoud
Copy link
Contributor Author

Thanks @5j9 for your great suggestion! I didn’t implement the __ne__ method in the #159 for that reason, but I missed its implementation in the date class.
This method has now been removed from both classes.

@slashmili slashmili merged commit 24c160a into slashmili:main Jan 26, 2025
8 checks passed
@slashmili
Copy link
Owner

Thanks @mobinghoveoud 🎉 !

@mobinghoveoud mobinghoveoud deleted the fix-datetime-ne branch January 26, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__ne__ fails for jdatetime.datetime vs datetime.datetime

3 participants