mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
[ruff
] Do not simplify round()
calls (RUF046
) (#14832)
## Summary Part 1 of the big change introduced in #14828. This temporarily causes all fixes for `round(...)` to be considered unsafe, but they will eventually be enhanced. ## Test Plan `cargo nextest run` and `cargo insta test`.
This commit is contained in:
parent
68eb0a2511
commit
c62ba48ad4
4 changed files with 569 additions and 374 deletions
|
@ -665,6 +665,14 @@ impl BuiltinTypeChecker for IntChecker {
|
|||
const EXPR_TYPE: PythonType = PythonType::Number(NumberLike::Integer);
|
||||
}
|
||||
|
||||
struct FloatChecker;
|
||||
|
||||
impl BuiltinTypeChecker for FloatChecker {
|
||||
const BUILTIN_TYPE_NAME: &'static str = "float";
|
||||
const TYPING_NAME: Option<&'static str> = None;
|
||||
const EXPR_TYPE: PythonType = PythonType::Number(NumberLike::Float);
|
||||
}
|
||||
|
||||
pub struct IoBaseChecker;
|
||||
|
||||
impl TypeChecker for IoBaseChecker {
|
||||
|
@ -850,6 +858,11 @@ pub fn is_int(binding: &Binding, semantic: &SemanticModel) -> bool {
|
|||
check_type::<IntChecker>(binding, semantic)
|
||||
}
|
||||
|
||||
/// Test whether the given binding can be considered an instance of `float`.
|
||||
pub fn is_float(binding: &Binding, semantic: &SemanticModel) -> bool {
|
||||
check_type::<FloatChecker>(binding, semantic)
|
||||
}
|
||||
|
||||
/// Test whether the given binding can be considered a set.
|
||||
///
|
||||
/// For this, we check what value might be associated with it through it's initialization and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue