From 54c5b4f71e842fa89892a412f4c07cc92f6437bf Mon Sep 17 00:00:00 2001 From: Kale Kundert Date: Fri, 2 Apr 2021 17:47:18 -0400 Subject: [PATCH] fix linting --- src/_pytest/python_api.py | 5 +++-- testing/python/approx.py | 13 ++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index dea8fc998..5595fc898 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -280,12 +280,13 @@ class ApproxScalar(ApproxBase): # numbers, which don't implement comparison operators. The second # requires that the actual and expected values can be compared. This # is necessary for comparing Decimals with floats, see #8495. + result: bool try: - result: bool = abs(self.expected - actual) <= self.tolerance + result = abs(self.expected - actual) <= self.tolerance except TypeError: low = self.expected - self.tolerance high = self.expected + self.tolerance - result: bool = low <= actual <= high + result = low <= actual <= high return result diff --git a/testing/python/approx.py b/testing/python/approx.py index a3c821adf..323a9adf7 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -276,15 +276,14 @@ class TestApprox: def test_decimal(self): within_1e6 = [ - (Decimal("1.0000005"), Decimal("1.0")), - (Decimal("-1.0000005"), Decimal("-1.0")), - (Decimal("1.0000005"), 1.0), - (Decimal("-1.0000005"), -1.0), + (Decimal("1.0000005"), Decimal("1.0"), Decimal), + (Decimal("-1.0000005"), Decimal("-1.0"), Decimal), + (Decimal("1.0000005"), 1.0, float), + (Decimal("-1.0000005"), -1.0, float), ] - for a, x in within_1e6: - T = type(x) + for a, x, T in within_1e6: # Need to test the default values here, because some code is needed - # to account for the facts that you can't add floats to decimals. + # to account for the fact that you can't add floats to decimals. assert a == approx(x) assert a == approx(x, rel=T("1e-6"), abs=0)