verbose-decimal-constructor (FURB157) has false negatives in Ruff 0.8.0 for some non-finite float strings. It recognizes the following strings case-insensitively in expressions like Decimal(float("inf")), but no others:
float strips white space. For example, Decimal(float(" nan ")) should be simplified to Decimal(" nan "). It could be further normalized to Decimal("NaN"), but FURB157 does not currently normalize other float strings, so I think it should keep the string argument unchanged.
float allows both signs for all non-finite values. Decimal(float("+inf")), Decimal(float("+infinity")), Decimal(float("+nan")), and Decimal(float("-nan")) should be simplified. FURB157 should not normalize these string arguments either, except for the last one. Decimal(float("-nan")) is equivalent to Decimal("nan"), not Decimal("-nan"), so for an argument of "-nan", the sign character should be deleted.
verbose-decimal-constructor
(FURB157) has false negatives in Ruff 0.8.0 for some non-finite float strings. It recognizes the following strings case-insensitively in expressions likeDecimal(float("inf"))
, but no others:https://github.com/astral-sh/ruff/blob/a90e404c3f010446ab8c18b4793c78834eeb65b7/crates/ruff_linter/src/rules/refurb/rules/verbose_decimal_constructor.rs#L157
float
strips white space. For example,Decimal(float(" nan "))
should be simplified toDecimal(" nan ")
. It could be further normalized toDecimal("NaN")
, but FURB157 does not currently normalize other float strings, so I think it should keep the string argument unchanged.float
allows both signs for all non-finite values.Decimal(float("+inf"))
,Decimal(float("+infinity"))
,Decimal(float("+nan"))
, andDecimal(float("-nan"))
should be simplified. FURB157 should not normalize these string arguments either, except for the last one.Decimal(float("-nan"))
is equivalent toDecimal("nan")
, notDecimal("-nan")
, so for an argument of"-nan"
, the sign character should be deleted.