data: Posting.is_payment casts threshold to address typing issue.
This commit is contained in:
parent
d8c7242208
commit
d9dca2cd68
1 changed files with 3 additions and 4 deletions
|
@ -25,6 +25,7 @@ import decimal
|
||||||
from beancount.core import account as bc_account
|
from beancount.core import account as bc_account
|
||||||
|
|
||||||
from typing import (
|
from typing import (
|
||||||
|
cast,
|
||||||
Iterable,
|
Iterable,
|
||||||
Iterator,
|
Iterator,
|
||||||
MutableMapping,
|
MutableMapping,
|
||||||
|
@ -212,13 +213,11 @@ class Posting(BasePosting):
|
||||||
meta: Metadata # type:ignore[assignment]
|
meta: Metadata # type:ignore[assignment]
|
||||||
|
|
||||||
def is_payment(self, threshold: DecimalCompat=0) -> bool:
|
def is_payment(self, threshold: DecimalCompat=0) -> bool:
|
||||||
|
threshold = cast(decimal.Decimal, threshold)
|
||||||
return (
|
return (
|
||||||
self.account.is_real_asset()
|
self.account.is_real_asset()
|
||||||
and self.units.number is not None
|
and self.units.number is not None
|
||||||
# mypy says abs returns an object and we can't negate that.
|
and self.units.number < -abs(threshold)
|
||||||
# Since we know threshold is numeric, it seems safe to assume
|
|
||||||
# the return value of abs is numeric as well.
|
|
||||||
and self.units.number < -abs(threshold) # type:ignore[operator]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue