Skip to content

Commit 80df448

Browse files
author
Baptiste Jonglez
committed
Reformat code with black and isort
1 parent 7466871 commit 80df448

File tree

5 files changed

+75
-56
lines changed

5 files changed

+75
-56
lines changed

ihatemoney/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ class BillForm(FlaskForm):
364364
payed_for = SelectMultipleField(
365365
_("For whom?"), validators=[DataRequired()], coerce=int
366366
)
367-
bill_type = SelectField(_("Bill Type"), choices=BillType.choices(), coerce=BillType, default=BillType.EXPENSE)
367+
bill_type = SelectField(
368+
_("Bill Type"),
369+
choices=BillType.choices(),
370+
coerce=BillType,
371+
default=BillType.EXPENSE,
372+
)
368373
submit = SubmitField(_("Submit"))
369374
submit2 = SubmitField(_("Submit and add a new one"))
370375

ihatemoney/migrations/versions/7a9b38559992_new_bill_type_attribute_added.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def upgrade():
1919
billtype_enum = sa.Enum(BillType)
2020
billtype_enum.create(op.get_bind(), checkfirst=True)
2121

22-
op.add_column("bill", sa.Column("bill_type", billtype_enum, server_default=BillType.EXPENSE.name))
22+
op.add_column(
23+
"bill",
24+
sa.Column("bill_type", billtype_enum, server_default=BillType.EXPENSE.name),
25+
)
2326
op.add_column("bill_version", sa.Column("bill_type", sa.UnicodeText()))
2427

2528

@@ -28,4 +31,4 @@ def downgrade():
2831
op.drop_column("bill_version", "bill_type")
2932

3033
billtype_enum = sa.Enum(BillType)
31-
billtype_enum.drop(op.get_bind())
34+
billtype_enum.drop(op.get_bind())

ihatemoney/models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import defaultdict
2-
from enum import Enum
32
import datetime
3+
from enum import Enum
44
import itertools
55

66
from dateutil.parser import parse
@@ -22,7 +22,7 @@
2222

2323
from ihatemoney.currency_convertor import CurrencyConverter
2424
from ihatemoney.monkeypath_continuum import PatchedTransactionFactory
25-
from ihatemoney.utils import generate_password_hash, get_members, same_bill, FormEnum
25+
from ihatemoney.utils import FormEnum, generate_password_hash, get_members, same_bill
2626
from ihatemoney.versioning import (
2727
ConditionalVersioningManager,
2828
LoggingMode,
@@ -51,6 +51,7 @@
5151
],
5252
)
5353

54+
5455
class BillType(Enum):
5556
EXPENSE = "Expense"
5657
REIMBURSEMENT = "Reimbursement"
@@ -131,7 +132,9 @@ def full_balance(self):
131132
if bill.bill_type == BillType.EXPENSE:
132133
should_receive[bill.payer.id] += bill.converted_amount
133134
for ower in bill.owers:
134-
should_pay[ower.id] += (ower.weight * bill.converted_amount / total_weight)
135+
should_pay[ower.id] += (
136+
ower.weight * bill.converted_amount / total_weight
137+
)
135138

136139
if bill.bill_type == BillType.REIMBURSEMENT:
137140
should_receive[bill.payer.id] += bill.converted_amount
@@ -563,7 +566,7 @@ def create_demo_project():
563566
("Alice", 20, ("Amina", "Alice"), "Beer !", "Expense"),
564567
("Amina", 50, ("Amina", "Alice", "Georg"), "AMAP", "Expense"),
565568
)
566-
for (payer, amount, owers, what, bill_type) in operations:
569+
for payer, amount, owers, what, bill_type in operations:
567570
db.session.add(
568571
Bill(
569572
amount=amount,

ihatemoney/tests/api_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,6 @@ def test_amount_too_high(self):
10171017
def test_validate_bill_type(self):
10181018
self.api_create("raclette")
10191019
self.api_add_member("raclette", "zorglub")
1020-
10211020

10221021
req = self.client.post(
10231022
"/api/projects/raclette/bills",
@@ -1029,7 +1028,7 @@ def test_validate_bill_type(self):
10291028
"bill_type": "wrong_bill_type",
10301029
"amount": "50",
10311030
},
1032-
headers=self.get_auth("raclette")
1031+
headers=self.get_auth("raclette"),
10331032
)
10341033

10351034
self.assertStatus(400, req)
@@ -1044,7 +1043,7 @@ def test_validate_bill_type(self):
10441043
"bill_type": "Expense",
10451044
"amount": "50",
10461045
},
1047-
headers=self.get_auth("raclette")
1046+
headers=self.get_auth("raclette"),
10481047
)
10491048

10501049
self.assertStatus(201, req)
@@ -1063,7 +1062,7 @@ def test_default_bill_type(self):
10631062
"payed_for": ["1"],
10641063
"amount": "50",
10651064
},
1066-
headers=self.get_auth("raclette")
1065+
headers=self.get_auth("raclette"),
10671066
)
10681067

10691068
self.assertStatus(201, req)
@@ -1076,4 +1075,3 @@ def test_default_bill_type(self):
10761075
# Bill type should now be "Expense"
10771076
got = json.loads(req.data.decode("utf-8"))
10781077
assert got["bill_type"] == "Expense"
1079-

0 commit comments

Comments
 (0)