mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-19 12:16:43 +00:00
float_comparison -> float-equality-comparison
This commit is contained in:
parent
7a75547544
commit
71f9deed88
5 changed files with 10 additions and 10 deletions
|
|
@ -1632,8 +1632,8 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) {
|
||||||
if checker.is_rule_enabled(Rule::YodaConditions) {
|
if checker.is_rule_enabled(Rule::YodaConditions) {
|
||||||
flake8_simplify::rules::yoda_conditions(checker, expr, left, ops, comparators);
|
flake8_simplify::rules::yoda_conditions(checker, expr, left, ops, comparators);
|
||||||
}
|
}
|
||||||
if checker.is_rule_enabled(Rule::FloatComparison) {
|
if checker.is_rule_enabled(Rule::FloatEqualityComparison) {
|
||||||
ruff::rules::float_comparison(checker, compare);
|
ruff::rules::float_equality_comparison(checker, compare);
|
||||||
}
|
}
|
||||||
if checker.is_rule_enabled(Rule::PandasNuniqueConstantSeriesCheck) {
|
if checker.is_rule_enabled(Rule::PandasNuniqueConstantSeriesCheck) {
|
||||||
pandas_vet::rules::nunique_constant_series_check(
|
pandas_vet::rules::nunique_constant_series_check(
|
||||||
|
|
|
||||||
|
|
@ -1059,7 +1059,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||||
(Ruff, "064") => rules::ruff::rules::NonOctalPermissions,
|
(Ruff, "064") => rules::ruff::rules::NonOctalPermissions,
|
||||||
(Ruff, "065") => rules::ruff::rules::LoggingEagerConversion,
|
(Ruff, "065") => rules::ruff::rules::LoggingEagerConversion,
|
||||||
|
|
||||||
(Ruff, "067") => rules::ruff::rules::FloatComparison,
|
(Ruff, "067") => rules::ruff::rules::FloatEqualityComparison,
|
||||||
|
|
||||||
(Ruff, "100") => rules::ruff::rules::UnusedNOQA,
|
(Ruff, "100") => rules::ruff::rules::UnusedNOQA,
|
||||||
(Ruff, "101") => rules::ruff::rules::RedirectedNOQA,
|
(Ruff, "101") => rules::ruff::rules::RedirectedNOQA,
|
||||||
|
|
|
||||||
|
|
@ -565,7 +565,7 @@ mod tests {
|
||||||
#[test_case(Rule::UnnecessaryRegularExpression, Path::new("RUF055_3.py"))]
|
#[test_case(Rule::UnnecessaryRegularExpression, Path::new("RUF055_3.py"))]
|
||||||
#[test_case(Rule::IndentedFormFeed, Path::new("RUF054.py"))]
|
#[test_case(Rule::IndentedFormFeed, Path::new("RUF054.py"))]
|
||||||
#[test_case(Rule::ImplicitClassVarInDataclass, Path::new("RUF045.py"))]
|
#[test_case(Rule::ImplicitClassVarInDataclass, Path::new("RUF045.py"))]
|
||||||
#[test_case(Rule::FloatComparison, Path::new("RUF067.py"))]
|
#[test_case(Rule::FloatEqualityComparison, Path::new("RUF067.py"))]
|
||||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||||
let snapshot = format!(
|
let snapshot = format!(
|
||||||
"preview__{}_{}",
|
"preview__{}_{}",
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,13 @@ use crate::{FixAvailability, Violation};
|
||||||
/// - [NumPy documentation: `numpy.isclose`](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html#numpy-isclose)
|
/// - [NumPy documentation: `numpy.isclose`](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html#numpy-isclose)
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
#[violation_metadata(preview_since = "0.14.3")]
|
#[violation_metadata(preview_since = "0.14.3")]
|
||||||
pub(crate) struct FloatComparison {
|
pub(crate) struct FloatEqualityComparison {
|
||||||
pub left: String,
|
pub left: String,
|
||||||
pub right: String,
|
pub right: String,
|
||||||
pub operand: String,
|
pub operand: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Violation for FloatComparison {
|
impl Violation for FloatEqualityComparison {
|
||||||
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
const FIX_AVAILABILITY: FixAvailability = FixAvailability::Sometimes;
|
||||||
|
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
|
|
@ -61,7 +61,7 @@ impl Violation for FloatComparison {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RUF067
|
/// RUF067
|
||||||
pub(crate) fn float_comparison(checker: &Checker, compare: &ast::ExprCompare) {
|
pub(crate) fn float_equality_comparison(checker: &Checker, compare: &ast::ExprCompare) {
|
||||||
let locator = checker.locator();
|
let locator = checker.locator();
|
||||||
let semantic = checker.semantic();
|
let semantic = checker.semantic();
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ pub(crate) fn float_comparison(checker: &Checker, compare: &ast::ExprCompare) {
|
||||||
.map(|((left, right), op)| (left, right, op))
|
.map(|((left, right), op)| (left, right, op))
|
||||||
{
|
{
|
||||||
checker.report_diagnostic(
|
checker.report_diagnostic(
|
||||||
FloatComparison {
|
FloatEqualityComparison {
|
||||||
left: locator.slice(left.range()).to_string(),
|
left: locator.slice(left.range()).to_string(),
|
||||||
right: locator.slice(right.range()).to_string(),
|
right: locator.slice(right.range()).to_string(),
|
||||||
operand: operand.to_string(),
|
operand: operand.to_string(),
|
||||||
|
|
@ -10,7 +10,7 @@ pub(crate) use decimal_from_float_literal::*;
|
||||||
pub(crate) use default_factory_kwarg::*;
|
pub(crate) use default_factory_kwarg::*;
|
||||||
pub(crate) use explicit_f_string_type_conversion::*;
|
pub(crate) use explicit_f_string_type_conversion::*;
|
||||||
pub(crate) use falsy_dict_get_fallback::*;
|
pub(crate) use falsy_dict_get_fallback::*;
|
||||||
pub(crate) use float_comparison::*;
|
pub(crate) use float_equality_comparison::*;
|
||||||
pub(crate) use function_call_in_dataclass_default::*;
|
pub(crate) use function_call_in_dataclass_default::*;
|
||||||
pub(crate) use if_key_in_dict_del::*;
|
pub(crate) use if_key_in_dict_del::*;
|
||||||
pub(crate) use implicit_classvar_in_dataclass::*;
|
pub(crate) use implicit_classvar_in_dataclass::*;
|
||||||
|
|
@ -75,7 +75,7 @@ mod decimal_from_float_literal;
|
||||||
mod default_factory_kwarg;
|
mod default_factory_kwarg;
|
||||||
mod explicit_f_string_type_conversion;
|
mod explicit_f_string_type_conversion;
|
||||||
mod falsy_dict_get_fallback;
|
mod falsy_dict_get_fallback;
|
||||||
mod float_comparison;
|
mod float_equality_comparison;
|
||||||
mod function_call_in_dataclass_default;
|
mod function_call_in_dataclass_default;
|
||||||
mod if_key_in_dict_del;
|
mod if_key_in_dict_del;
|
||||||
mod implicit_classvar_in_dataclass;
|
mod implicit_classvar_in_dataclass;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue