From d9dca2cd686b667bbf1bfd1708f5b6313d2d5ce7 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sun, 29 Mar 2020 15:32:51 -0400 Subject: [PATCH] data: Posting.is_payment casts threshold to address typing issue. --- conservancy_beancount/data.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/conservancy_beancount/data.py b/conservancy_beancount/data.py index a6d8ae7..ddb3196 100644 --- a/conservancy_beancount/data.py +++ b/conservancy_beancount/data.py @@ -25,6 +25,7 @@ import decimal from beancount.core import account as bc_account from typing import ( + cast, Iterable, Iterator, MutableMapping, @@ -212,13 +213,11 @@ class Posting(BasePosting): meta: Metadata # type:ignore[assignment] def is_payment(self, threshold: DecimalCompat=0) -> bool: + threshold = cast(decimal.Decimal, threshold) return ( self.account.is_real_asset() and self.units.number is not None - # mypy says abs returns an object and we can't negate that. - # 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] + and self.units.number < -abs(threshold) )