[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:
InSync 2024-12-09 22:51:27 +07:00 committed by GitHub
parent 68eb0a2511
commit c62ba48ad4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 569 additions and 374 deletions

View file

@ -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