---
source: crates/ruff_linter/src/rules/ruff/mod.rs
---
RUF057.py:6:1: RUF057 [*] Value being rounded is already an integer
  |
6 | round(42)                                         # Error (safe)
  | ^^^^^^^^^ RUF057
7 | round(42, None)                                   # Error (safe)
8 | round(42, 2)                                      # Error (safe)
  |
  = help: Remove unnecessary `round` call

ℹ Safe fix
3 3 | 
4 4 | 
5 5 | 
6   |-round(42)                                         # Error (safe)
  6 |+42                                         # Error (safe)
7 7 | round(42, None)                                   # Error (safe)
8 8 | round(42, 2)                                      # Error (safe)
9 9 | round(42, -2)                                     # No error

RUF057.py:7:1: RUF057 [*] Value being rounded is already an integer
  |
6 | round(42)                                         # Error (safe)
7 | round(42, None)                                   # Error (safe)
  | ^^^^^^^^^^^^^^^ RUF057
8 | round(42, 2)                                      # Error (safe)
9 | round(42, -2)                                     # No error
  |
  = help: Remove unnecessary `round` call

ℹ Safe fix
4 4 | 
5 5 | 
6 6 | round(42)                                         # Error (safe)
7   |-round(42, None)                                   # Error (safe)
  7 |+42                                   # Error (safe)
8 8 | round(42, 2)                                      # Error (safe)
9 9 | round(42, -2)                                     # No error
10 10 | round(42, inferred_int)                           # No error

RUF057.py:8:1: RUF057 [*] Value being rounded is already an integer
   |
 6 | round(42)                                         # Error (safe)
 7 | round(42, None)                                   # Error (safe)
 8 | round(42, 2)                                      # Error (safe)
   | ^^^^^^^^^^^^ RUF057
 9 | round(42, -2)                                     # No error
10 | round(42, inferred_int)                           # No error
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
5 5 | 
6 6 | round(42)                                         # Error (safe)
7 7 | round(42, None)                                   # Error (safe)
8   |-round(42, 2)                                      # Error (safe)
  8 |+42                                      # Error (safe)
9 9 | round(42, -2)                                     # No error
10 10 | round(42, inferred_int)                           # No error
11 11 | round(42, 3 + 4)                                  # No error

RUF057.py:24:1: RUF057 [*] Value being rounded is already an integer
   |
24 | round(4 + 2)                                      # Error (safe)
   | ^^^^^^^^^^^^ RUF057
25 | round(4 + 2, None)                                # Error (safe)
26 | round(4 + 2, 2)                                   # Error (safe)
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
21 21 | round(42., foo)                                   # No error
22 22 | 
23 23 | 
24    |-round(4 + 2)                                      # Error (safe)
   24 |+4 + 2                                      # Error (safe)
25 25 | round(4 + 2, None)                                # Error (safe)
26 26 | round(4 + 2, 2)                                   # Error (safe)
27 27 | round(4 + 2, -2)                                  # No error

RUF057.py:25:1: RUF057 [*] Value being rounded is already an integer
   |
24 | round(4 + 2)                                      # Error (safe)
25 | round(4 + 2, None)                                # Error (safe)
   | ^^^^^^^^^^^^^^^^^^ RUF057
26 | round(4 + 2, 2)                                   # Error (safe)
27 | round(4 + 2, -2)                                  # No error
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
22 22 | 
23 23 | 
24 24 | round(4 + 2)                                      # Error (safe)
25    |-round(4 + 2, None)                                # Error (safe)
   25 |+4 + 2                                # Error (safe)
26 26 | round(4 + 2, 2)                                   # Error (safe)
27 27 | round(4 + 2, -2)                                  # No error
28 28 | round(4 + 2, inferred_int)                        # No error

RUF057.py:26:1: RUF057 [*] Value being rounded is already an integer
   |
24 | round(4 + 2)                                      # Error (safe)
25 | round(4 + 2, None)                                # Error (safe)
26 | round(4 + 2, 2)                                   # Error (safe)
   | ^^^^^^^^^^^^^^^ RUF057
27 | round(4 + 2, -2)                                  # No error
28 | round(4 + 2, inferred_int)                        # No error
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
23 23 | 
24 24 | round(4 + 2)                                      # Error (safe)
25 25 | round(4 + 2, None)                                # Error (safe)
26    |-round(4 + 2, 2)                                   # Error (safe)
   26 |+4 + 2                                   # Error (safe)
27 27 | round(4 + 2, -2)                                  # No error
28 28 | round(4 + 2, inferred_int)                        # No error
29 29 | round(4 + 2, 3 + 4)                               # No error

RUF057.py:42:1: RUF057 [*] Value being rounded is already an integer
   |
42 | round(inferred_int)                               # Error (unsafe)
   | ^^^^^^^^^^^^^^^^^^^ RUF057
43 | round(inferred_int, None)                         # Error (unsafe)
44 | round(inferred_int, 2)                            # Error (unsafe)
   |
   = help: Remove unnecessary `round` call

ℹ Unsafe fix
39 39 | round(4. + 2., foo)                               # No error
40 40 | 
41 41 | 
42    |-round(inferred_int)                               # Error (unsafe)
   42 |+inferred_int                               # Error (unsafe)
43 43 | round(inferred_int, None)                         # Error (unsafe)
44 44 | round(inferred_int, 2)                            # Error (unsafe)
45 45 | round(inferred_int, -2)                           # No error

RUF057.py:43:1: RUF057 [*] Value being rounded is already an integer
   |
42 | round(inferred_int)                               # Error (unsafe)
43 | round(inferred_int, None)                         # Error (unsafe)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF057
44 | round(inferred_int, 2)                            # Error (unsafe)
45 | round(inferred_int, -2)                           # No error
   |
   = help: Remove unnecessary `round` call

ℹ Unsafe fix
40 40 | 
41 41 | 
42 42 | round(inferred_int)                               # Error (unsafe)
43    |-round(inferred_int, None)                         # Error (unsafe)
   43 |+inferred_int                         # Error (unsafe)
44 44 | round(inferred_int, 2)                            # Error (unsafe)
45 45 | round(inferred_int, -2)                           # No error
46 46 | round(inferred_int, inferred_int)                 # No error

RUF057.py:44:1: RUF057 [*] Value being rounded is already an integer
   |
42 | round(inferred_int)                               # Error (unsafe)
43 | round(inferred_int, None)                         # Error (unsafe)
44 | round(inferred_int, 2)                            # Error (unsafe)
   | ^^^^^^^^^^^^^^^^^^^^^^ RUF057
45 | round(inferred_int, -2)                           # No error
46 | round(inferred_int, inferred_int)                 # No error
   |
   = help: Remove unnecessary `round` call

ℹ Unsafe fix
41 41 | 
42 42 | round(inferred_int)                               # Error (unsafe)
43 43 | round(inferred_int, None)                         # Error (unsafe)
44    |-round(inferred_int, 2)                            # Error (unsafe)
   44 |+inferred_int                            # Error (unsafe)
45 45 | round(inferred_int, -2)                           # No error
46 46 | round(inferred_int, inferred_int)                 # No error
47 47 | round(inferred_int, 3 + 4)                        # No error

RUF057.py:71:1: RUF057 [*] Value being rounded is already an integer
   |
69 |   # contains newline.
70 |   # See https://github.com/astral-sh/ruff/issues/15598
71 | / round(-
72 | | 1)
   | |__^ RUF057
73 |   round(1
74 |   *1
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
68 68 | # Fixes should preserve parentheses when argument
69 69 | # contains newline.
70 70 | # See https://github.com/astral-sh/ruff/issues/15598
71    |-round(-
   71 |+(-
72 72 | 1)
73 73 | round(1
74 74 | *1

RUF057.py:73:1: RUF057 [*] Value being rounded is already an integer
   |
71 |   round(-
72 |   1)
73 | / round(1
74 | | *1
75 | | )
   | |_^ RUF057
76 |
77 |   # fix should be unsafe if comment is in call range
   |
   = help: Remove unnecessary `round` call

ℹ Safe fix
70 70 | # See https://github.com/astral-sh/ruff/issues/15598
71 71 | round(-
72 72 | 1)
73    |-round(1
74    |-*1
75    |-)
   73 |+(1
   74 |+*1)
76 75 | 
77 76 | # fix should be unsafe if comment is in call range
78 77 | round(# a comment

RUF057.py:78:1: RUF057 [*] Value being rounded is already an integer
   |
77 |   # fix should be unsafe if comment is in call range
78 | / round(# a comment
79 | | 17
80 | | )
   | |_^ RUF057
81 |   round(
82 |       17 # a comment
   |
   = help: Remove unnecessary `round` call

ℹ Unsafe fix
75 75 | )
76 76 | 
77 77 | # fix should be unsafe if comment is in call range
78    |-round(# a comment
79 78 | 17
80    |-)
81 79 | round(
82 80 |     17 # a comment
83 81 | )

RUF057.py:81:1: RUF057 [*] Value being rounded is already an integer
   |
79 |   17
80 |   )
81 | / round(
82 | |     17 # a comment
83 | | )
   | |_^ RUF057
   |
   = help: Remove unnecessary `round` call

ℹ Unsafe fix
78 78 | round(# a comment
79 79 | 17
80 80 | )
81    |-round(
82    |-    17 # a comment
83    |-)
   81 |+17
