nebius/SWE-bench-extra huggingface dataset:
Repository: mirumee/prices

Issue:
Price can be created with net and gross with different currencies
Right now we allow to create Price with net Amount and gross Amount with different currencies.
`Price(net=Amount('25', 'USD'), gross=Amount('30', 'EUR'))`
This should not be allowed and should rise an exception.

Comments:

Patch:
diff --git a/prices/price.py b/prices/price.py
index ffc15bb..549dfab 100644
--- a/prices/price.py
+++ b/prices/price.py
@@ -14,6 +14,10 @@ class Price(object):
         if not isinstance(net, Amount) or not isinstance(gross, Amount):
             raise TypeError('Price requires two amounts, got %r, %r' % (
                 net, gross))
+        if net.currency != gross.currency:
+            raise ValueError(
+                'Amounts given in different currencies: %r and %r' % (
+                    net.currency, gross.currency))
         self.net = net
         self.gross = gross
 
diff --git a/setup.py b/setup.py
index 7b0a652..02f7aac 100755
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ setup(
     author_email='hello@mirumee.com',
     description='Python price handling for humans',
     license='BSD',
-    version='1.0.0-beta',
+    version='1.0.1-beta',
     url='https://github.com/mirumee/prices',
     packages=['prices'],
     install_requires=['babel'],


Test patch:
diff --git a/tests/test_price.py b/tests/test_price.py
index 9f2f214..2a7465c 100644
--- a/tests/test_price.py
+++ b/tests/test_price.py
@@ -10,6 +10,11 @@ def test_construction():
         Price(1, 1)
 
 
+def test_construction_different_currencies():
+    with pytest.raises(ValueError):
+        Price(net=Amount(1, 'USD'), gross=Amount(2, 'EUR'))
+
+
 def test_addition():
     price1 = Price(Amount(10, 'USD'), Amount(15, 'USD'))
     price2 = Price(Amount(20, 'USD'), Amount(30, 'USD'))