From 835173782f52e36704f21af130a223825cd9b376 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Tue, 11 Jul 2023 10:15:14 +0100 Subject: [PATCH 1/3] chore: Fix failing tests (ignore S307 "possibly insecure function") --- arithmetic_analysis/newton_raphson.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index aee2f07e5743..b740b81edc8a 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -25,9 +25,9 @@ def newton_raphson( """ x = a while True: - x = Decimal(x) - (Decimal(eval(func)) / Decimal(eval(str(diff(func))))) + x = Decimal(x) - (Decimal(eval(func)) / Decimal(eval(str(diff(func))))) # noqa: S307 # This number dictates the accuracy of the answer - if abs(eval(func)) < precision: + if abs(eval(func)) < precision: # noqa: S307 return float(x) From 4a644ea558773124a6d879b4889274d047d266f3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 09:16:52 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- arithmetic_analysis/newton_raphson.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index b740b81edc8a..928c456cd3bf 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -25,7 +25,9 @@ def newton_raphson( """ x = a while True: - x = Decimal(x) - (Decimal(eval(func)) / Decimal(eval(str(diff(func))))) # noqa: S307 + x = Decimal(x) - ( + Decimal(eval(func)) / Decimal(eval(str(diff(func)))) + ) # noqa: S307 # This number dictates the accuracy of the answer if abs(eval(func)) < precision: # noqa: S307 return float(x) From 7fe1028d163e54b27e338e7f1521b289b8351322 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Tue, 11 Jul 2023 10:18:36 +0100 Subject: [PATCH 3/3] fix: Move noqa back to right line --- arithmetic_analysis/newton_raphson.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arithmetic_analysis/newton_raphson.py b/arithmetic_analysis/newton_raphson.py index 928c456cd3bf..1b90ad4177f6 100644 --- a/arithmetic_analysis/newton_raphson.py +++ b/arithmetic_analysis/newton_raphson.py @@ -26,8 +26,8 @@ def newton_raphson( x = a while True: x = Decimal(x) - ( - Decimal(eval(func)) / Decimal(eval(str(diff(func)))) - ) # noqa: S307 + Decimal(eval(func)) / Decimal(eval(str(diff(func)))) # noqa: S307 + ) # This number dictates the accuracy of the answer if abs(eval(func)) < precision: # noqa: S307 return float(x)