min
builtin PTC-W0041invoice_amount = min(invoice_amount, ticket_fee_maximum)
instead of the unnecessary if block120 start=latest_invoice_date, end=self.issued_at
121 )
122 invoice_amount = gross_revenue * (ticket_fee_percentage / 100)
123 if invoice_amount > ticket_fee_maximum:124 invoice_amount = ticket_fee_maximum
125 self.amount = round_money(invoice_amount)
126 if not force and self.amount == 0:
It is unnecessary to use an if
statement to check the minimum of two values and then assign the value to a name.
You can use the min
built-in do do this. It is straightforward and more readable.
Not preferred:
if value >= 10:
value = 10
Preferred:
value = min(value, 10)