From 52e7020448ead08b4a31b8f6e02a7c87d4d15852 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 26 Dec 2023 21:18:35 -0600 Subject: [PATCH 1/5] [`refurb`] Avoid false positives for `math-constant` (`FURB152`) --- .../resources/test/fixtures/refurb/FURB152.py | 20 ++ .../src/rules/refurb/rules/math_constant.rs | 20 +- ...es__refurb__tests__FURB152_FURB152.py.snap | 199 +++++++++++++++++- 3 files changed, 228 insertions(+), 11 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py index e9339a86fcd3d..6a16fb89198e2 100644 --- a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py +++ b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py @@ -10,6 +10,26 @@ r = 3.141 # FURB152 +r = 3.142 # FURB152 + r = 3.1415 # FURB152 +r = 3.1416 # FURB152 + +r = 3.141592 # FURB152 + +r = 3.141593 # FURB152 + +r = 3.14159265 # FURB152 + +r = 3.14159266 # OK + e = 2.7 # OK + +e = 2.7182 # FURB152 + +e = 2.7183 # FURB152 + +e = 2.71824 # OK + +e = 2.71820001 # OK diff --git a/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs b/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs index 23ef1aa8c1d21..d93ce24525bd5 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs @@ -83,6 +83,20 @@ fn convert_to_constant( )) } +fn matches_constant(constant: f64, value: f64) -> bool { + for point in 2..=15 { + let rounded = (constant * 10_f64.powi(point)).round() / 10_f64.powi(point); + if rounded == value { + return true; + } + let rounded = (constant * 10_f64.powi(point)).floor() / 10_f64.powi(point); + if rounded == value { + return true; + } + } + false +} + #[derive(Debug, Clone, Copy)] enum Constant { Pi, @@ -94,11 +108,11 @@ impl Constant { #[allow(clippy::approx_constant)] fn from_value(value: f64) -> Option { if (3.14..3.15).contains(&value) { - Some(Self::Pi) + matches_constant(std::f64::consts::PI, value).then_some(Self::Pi) } else if (2.71..2.72).contains(&value) { - Some(Self::E) + matches_constant(std::f64::consts::E, value).then_some(Self::E) } else if (6.28..6.29).contains(&value) { - Some(Self::Tau) + matches_constant(std::f64::consts::TAU, value).then_some(Self::Tau) } else { None } diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 094f30df73e58..46775fba26e80 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -77,7 +77,7 @@ FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` 11 | r = 3.141 # FURB152 | ^^^^^ FURB152 12 | -13 | r = 3.1415 # FURB152 +13 | r = 3.142 # FURB152 | = help: Use `math.pi` @@ -93,17 +93,17 @@ FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` 11 |-r = 3.141 # FURB152 12 |+r = math.pi # FURB152 12 13 | -13 14 | r = 3.1415 # FURB152 +13 14 | r = 3.142 # FURB152 14 15 | -FURB152.py:13:5: FURB152 [*] Replace `3.1415` with `math.pi` +FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` | 11 | r = 3.141 # FURB152 12 | -13 | r = 3.1415 # FURB152 - | ^^^^^^ FURB152 +13 | r = 3.142 # FURB152 + | ^^^^^ FURB152 14 | -15 | e = 2.7 # OK +15 | r = 3.1415 # FURB152 | = help: Use `math.pi` @@ -116,9 +116,192 @@ FURB152.py:13:5: FURB152 [*] Replace `3.1415` with `math.pi` 10 11 | 11 12 | r = 3.141 # FURB152 12 13 | -13 |-r = 3.1415 # FURB152 +13 |-r = 3.142 # FURB152 14 |+r = math.pi # FURB152 14 15 | -15 16 | e = 2.7 # OK +15 16 | r = 3.1415 # FURB152 +16 17 | + +FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` + | +13 | r = 3.142 # FURB152 +14 | +15 | r = 3.1415 # FURB152 + | ^^^^^^ FURB152 +16 | +17 | r = 3.1416 # FURB152 + | + = help: Use `math.pi` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +12 13 | +13 14 | r = 3.142 # FURB152 +14 15 | +15 |-r = 3.1415 # FURB152 + 16 |+r = math.pi # FURB152 +16 17 | +17 18 | r = 3.1416 # FURB152 +18 19 | + +FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` + | +15 | r = 3.1415 # FURB152 +16 | +17 | r = 3.1416 # FURB152 + | ^^^^^^ FURB152 +18 | +19 | r = 3.141592 # FURB152 + | + = help: Use `math.pi` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +14 15 | +15 16 | r = 3.1415 # FURB152 +16 17 | +17 |-r = 3.1416 # FURB152 + 18 |+r = math.pi # FURB152 +18 19 | +19 20 | r = 3.141592 # FURB152 +20 21 | + +FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` + | +17 | r = 3.1416 # FURB152 +18 | +19 | r = 3.141592 # FURB152 + | ^^^^^^^^ FURB152 +20 | +21 | r = 3.141593 # FURB152 + | + = help: Use `math.pi` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +16 17 | +17 18 | r = 3.1416 # FURB152 +18 19 | +19 |-r = 3.141592 # FURB152 + 20 |+r = math.pi # FURB152 +20 21 | +21 22 | r = 3.141593 # FURB152 +22 23 | + +FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` + | +19 | r = 3.141592 # FURB152 +20 | +21 | r = 3.141593 # FURB152 + | ^^^^^^^^ FURB152 +22 | +23 | r = 3.14159265 # FURB152 + | + = help: Use `math.pi` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +18 19 | +19 20 | r = 3.141592 # FURB152 +20 21 | +21 |-r = 3.141593 # FURB152 + 22 |+r = math.pi # FURB152 +22 23 | +23 24 | r = 3.14159265 # FURB152 +24 25 | + +FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` + | +21 | r = 3.141593 # FURB152 +22 | +23 | r = 3.14159265 # FURB152 + | ^^^^^^^^^^ FURB152 +24 | +25 | r = 3.14159266 # OK + | + = help: Use `math.pi` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +20 21 | +21 22 | r = 3.141593 # FURB152 +22 23 | +23 |-r = 3.14159265 # FURB152 + 24 |+r = math.pi # FURB152 +24 25 | +25 26 | r = 3.14159266 # OK +26 27 | + +FURB152.py:29:5: FURB152 [*] Replace `2.7182` with `math.e` + | +27 | e = 2.7 # OK +28 | +29 | e = 2.7182 # FURB152 + | ^^^^^^ FURB152 +30 | +31 | e = 2.7183 # FURB152 + | + = help: Use `math.e` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +26 27 | +27 28 | e = 2.7 # OK +28 29 | +29 |-e = 2.7182 # FURB152 + 30 |+e = math.e # FURB152 +30 31 | +31 32 | e = 2.7183 # FURB152 +32 33 | + +FURB152.py:31:5: FURB152 [*] Replace `2.7183` with `math.e` + | +29 | e = 2.7182 # FURB152 +30 | +31 | e = 2.7183 # FURB152 + | ^^^^^^ FURB152 +32 | +33 | e = 2.71824 # OK + | + = help: Use `math.e` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +28 29 | +29 30 | e = 2.7182 # FURB152 +30 31 | +31 |-e = 2.7183 # FURB152 + 32 |+e = math.e # FURB152 +32 33 | +33 34 | e = 2.71824 # OK +34 35 | From 35869b91776344aa5e2fac2ec4780678bf05adb8 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 26 Dec 2023 21:21:47 -0600 Subject: [PATCH 2/5] . --- .../resources/test/fixtures/refurb/FURB152.py | 4 ++ ...es__refurb__tests__FURB152_FURB152.py.snap | 52 ++++++++++++++----- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py index 6a16fb89198e2..e378834be8a36 100644 --- a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py +++ b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py @@ -26,10 +26,14 @@ e = 2.7 # OK +e = 2.718 # FURB152 + e = 2.7182 # FURB152 e = 2.7183 # FURB152 +e = 2.719 # OK + e = 2.71824 # OK e = 2.71820001 # OK diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 46775fba26e80..098e830ffcac8 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -252,14 +252,14 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` 25 26 | r = 3.14159266 # OK 26 27 | -FURB152.py:29:5: FURB152 [*] Replace `2.7182` with `math.e` +FURB152.py:29:5: FURB152 [*] Replace `2.718` with `math.e` | 27 | e = 2.7 # OK 28 | -29 | e = 2.7182 # FURB152 - | ^^^^^^ FURB152 +29 | e = 2.718 # FURB152 + | ^^^^^ FURB152 30 | -31 | e = 2.7183 # FURB152 +31 | e = 2.7182 # FURB152 | = help: Use `math.e` @@ -272,20 +272,20 @@ FURB152.py:29:5: FURB152 [*] Replace `2.7182` with `math.e` 26 27 | 27 28 | e = 2.7 # OK 28 29 | -29 |-e = 2.7182 # FURB152 +29 |-e = 2.718 # FURB152 30 |+e = math.e # FURB152 30 31 | -31 32 | e = 2.7183 # FURB152 +31 32 | e = 2.7182 # FURB152 32 33 | -FURB152.py:31:5: FURB152 [*] Replace `2.7183` with `math.e` +FURB152.py:31:5: FURB152 [*] Replace `2.7182` with `math.e` | -29 | e = 2.7182 # FURB152 +29 | e = 2.718 # FURB152 30 | -31 | e = 2.7183 # FURB152 +31 | e = 2.7182 # FURB152 | ^^^^^^ FURB152 32 | -33 | e = 2.71824 # OK +33 | e = 2.7183 # FURB152 | = help: Use `math.e` @@ -296,12 +296,38 @@ FURB152.py:31:5: FURB152 [*] Replace `2.7183` with `math.e` 3 4 | A = 3.14 * r ** 2 # FURB152 -------------------------------------------------------------------------------- 28 29 | -29 30 | e = 2.7182 # FURB152 +29 30 | e = 2.718 # FURB152 30 31 | -31 |-e = 2.7183 # FURB152 +31 |-e = 2.7182 # FURB152 32 |+e = math.e # FURB152 32 33 | -33 34 | e = 2.71824 # OK +33 34 | e = 2.7183 # FURB152 +34 35 | + +FURB152.py:33:5: FURB152 [*] Replace `2.7183` with `math.e` + | +31 | e = 2.7182 # FURB152 +32 | +33 | e = 2.7183 # FURB152 + | ^^^^^^ FURB152 +34 | +35 | e = 2.719 # OK + | + = help: Use `math.e` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +30 31 | +31 32 | e = 2.7182 # FURB152 +32 33 | +33 |-e = 2.7183 # FURB152 + 34 |+e = math.e # FURB152 34 35 | +35 36 | e = 2.719 # OK +36 37 | From 2069320b73650ec4ca355b4ff826766af0f5ba33 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 26 Dec 2023 21:23:32 -0600 Subject: [PATCH 3/5] . --- .../resources/test/fixtures/refurb/FURB152.py | 2 + ...es__refurb__tests__FURB152_FURB152.py.snap | 88 ++++++++++++------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py index e378834be8a36..9d54d7cb8f007 100644 --- a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py +++ b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py @@ -22,6 +22,8 @@ r = 3.14159265 # FURB152 +r = 3.141592653589793238462643383279 # FURB152 + r = 3.14159266 # OK e = 2.7 # OK diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 098e830ffcac8..1a0f6a717e87d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -233,7 +233,7 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` 23 | r = 3.14159265 # FURB152 | ^^^^^^^^^^ FURB152 24 | -25 | r = 3.14159266 # OK +25 | r = 3.141592653589793238462643383279 # FURB152 | = help: Use `math.pi` @@ -249,19 +249,19 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` 23 |-r = 3.14159265 # FURB152 24 |+r = math.pi # FURB152 24 25 | -25 26 | r = 3.14159266 # OK +25 26 | r = 3.141592653589793238462643383279 # FURB152 26 27 | -FURB152.py:29:5: FURB152 [*] Replace `2.718` with `math.e` +FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `math.pi` | -27 | e = 2.7 # OK -28 | -29 | e = 2.718 # FURB152 - | ^^^^^ FURB152 -30 | -31 | e = 2.7182 # FURB152 +23 | r = 3.14159265 # FURB152 +24 | +25 | r = 3.141592653589793238462643383279 # FURB152 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB152 +26 | +27 | r = 3.14159266 # OK | - = help: Use `math.e` + = help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -269,23 +269,23 @@ FURB152.py:29:5: FURB152 [*] Replace `2.718` with `math.e` 2 3 | 3 4 | A = 3.14 * r ** 2 # FURB152 -------------------------------------------------------------------------------- +22 23 | +23 24 | r = 3.14159265 # FURB152 +24 25 | +25 |-r = 3.141592653589793238462643383279 # FURB152 + 26 |+r = math.pi # FURB152 26 27 | -27 28 | e = 2.7 # OK +27 28 | r = 3.14159266 # OK 28 29 | -29 |-e = 2.718 # FURB152 - 30 |+e = math.e # FURB152 -30 31 | -31 32 | e = 2.7182 # FURB152 -32 33 | -FURB152.py:31:5: FURB152 [*] Replace `2.7182` with `math.e` +FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` | -29 | e = 2.718 # FURB152 +29 | e = 2.7 # OK 30 | -31 | e = 2.7182 # FURB152 - | ^^^^^^ FURB152 +31 | e = 2.718 # FURB152 + | ^^^^^ FURB152 32 | -33 | e = 2.7183 # FURB152 +33 | e = 2.7182 # FURB152 | = help: Use `math.e` @@ -296,22 +296,22 @@ FURB152.py:31:5: FURB152 [*] Replace `2.7182` with `math.e` 3 4 | A = 3.14 * r ** 2 # FURB152 -------------------------------------------------------------------------------- 28 29 | -29 30 | e = 2.718 # FURB152 +29 30 | e = 2.7 # OK 30 31 | -31 |-e = 2.7182 # FURB152 +31 |-e = 2.718 # FURB152 32 |+e = math.e # FURB152 32 33 | -33 34 | e = 2.7183 # FURB152 +33 34 | e = 2.7182 # FURB152 34 35 | -FURB152.py:33:5: FURB152 [*] Replace `2.7183` with `math.e` +FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` | -31 | e = 2.7182 # FURB152 +31 | e = 2.718 # FURB152 32 | -33 | e = 2.7183 # FURB152 +33 | e = 2.7182 # FURB152 | ^^^^^^ FURB152 34 | -35 | e = 2.719 # OK +35 | e = 2.7183 # FURB152 | = help: Use `math.e` @@ -322,12 +322,38 @@ FURB152.py:33:5: FURB152 [*] Replace `2.7183` with `math.e` 3 4 | A = 3.14 * r ** 2 # FURB152 -------------------------------------------------------------------------------- 30 31 | -31 32 | e = 2.7182 # FURB152 +31 32 | e = 2.718 # FURB152 32 33 | -33 |-e = 2.7183 # FURB152 +33 |-e = 2.7182 # FURB152 34 |+e = math.e # FURB152 34 35 | -35 36 | e = 2.719 # OK +35 36 | e = 2.7183 # FURB152 +36 37 | + +FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` + | +33 | e = 2.7182 # FURB152 +34 | +35 | e = 2.7183 # FURB152 + | ^^^^^^ FURB152 +36 | +37 | e = 2.719 # OK + | + = help: Use `math.e` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +32 33 | +33 34 | e = 2.7182 # FURB152 +34 35 | +35 |-e = 2.7183 # FURB152 + 36 |+e = math.e # FURB152 36 37 | +37 38 | e = 2.719 # OK +38 39 | From 12973392d6b39b3c64e752dec6994fd36783e970 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 26 Dec 2023 21:27:51 -0600 Subject: [PATCH 4/5] . --- crates/ruff_linter/src/rules/refurb/rules/math_constant.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs b/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs index d93ce24525bd5..6ec50d7c68a12 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/math_constant.rs @@ -86,11 +86,11 @@ fn convert_to_constant( fn matches_constant(constant: f64, value: f64) -> bool { for point in 2..=15 { let rounded = (constant * 10_f64.powi(point)).round() / 10_f64.powi(point); - if rounded == value { + if (rounded - value).abs() < f64::EPSILON { return true; } let rounded = (constant * 10_f64.powi(point)).floor() / 10_f64.powi(point); - if rounded == value { + if (rounded - value).abs() < f64::EPSILON { return true; } } From 934cd110f5de96c3b56e936cb3fc9332594d5190 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 26 Dec 2023 21:31:10 -0600 Subject: [PATCH 5/5] . --- .../resources/test/fixtures/refurb/FURB152.py | 4 ++++ ...es__refurb__tests__FURB152_FURB152.py.snap | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py index 9d54d7cb8f007..598d811d75e7c 100644 --- a/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py +++ b/crates/ruff_linter/resources/test/fixtures/refurb/FURB152.py @@ -39,3 +39,7 @@ e = 2.71824 # OK e = 2.71820001 # OK + +e = 2.718200000000001 # OK + +e = 2.7182000000000001 # FURB152 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index 1a0f6a717e87d..9933f51589ab9 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -356,4 +356,25 @@ FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` 37 38 | e = 2.719 # OK 38 39 | +FURB152.py:45:5: FURB152 [*] Replace `2.7182000000000001` with `math.e` + | +43 | e = 2.718200000000001 # OK +44 | +45 | e = 2.7182000000000001 # FURB152 + | ^^^^^^^^^^^^^^^^^^ FURB152 + | + = help: Use `math.e` + +ℹ Safe fix + 1 |+import math +1 2 | r = 3.1 # OK +2 3 | +3 4 | A = 3.14 * r ** 2 # FURB152 +-------------------------------------------------------------------------------- +42 43 | +43 44 | e = 2.718200000000001 # OK +44 45 | +45 |-e = 2.7182000000000001 # FURB152 + 46 |+e = math.e # FURB152 +