Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__eq__ is too rigid #10

Open
avanov opened this issue Jun 10, 2019 · 2 comments
Open

__eq__ is too rigid #10

avanov opened this issue Jun 10, 2019 · 2 comments

Comments

@avanov
Copy link

avanov commented Jun 10, 2019

Hi!

The current implementation of __eq__ for Money is too rigid and cannot be used for inclusion tests:

>>> from money.currency import Currency
>>> from money.money import Money
>>> x = Money('10.00', Currency.USD)
>>> x in (None, Money('10.00', Currency.USD))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<...>/lib/python3.7/site-packages/money/money.py", line 80, in __eq__
    raise InvalidOperandError
money.exceptions.InvalidOperandError: Invalid operand types for operation
>>> x in (Money('10.00', Currency.USD), None)
True
@nickyr
Copy link
Contributor

nickyr commented Jun 17, 2019

Sorry I haven't had a chance to respond...was on vacation and I've been busy catching up. It does look like this should be fixed. Feel free to open a pull request, if not, I'll try to do one in the near future.

suspectpart added a commit to suspectpart/py-money that referenced this issue Oct 17, 2020
@suspectpart
Copy link

I created a PR as I plan to use this library and would like to have the __eq__ behavior fixed. Happy to perform additional changes if that fix is not appropriate yet.

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

No branches or pull requests

3 participants