---
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
snapshot_kind: text
---
SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  |
1 | if isinstance(a, int) or isinstance(a, float):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
2 |     pass
  |
  = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
1   |-if isinstance(a, int) or isinstance(a, float):  # SIM101
  1 |+if isinstance(a, (int, float)):  # SIM101
2 2 |     pass
3 3 | 
4 4 | if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101

SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  |
2 |     pass
3 | 
4 | if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
5 |     pass
  |
  = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
1 1 | if isinstance(a, int) or isinstance(a, float):  # SIM101
2 2 |     pass
3 3 | 
4   |-if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101
  4 |+if isinstance(a, (int, float, bool)):  # SIM101
5 5 |     pass
6 6 | 
7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool):  # SIM101

SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  |
5 |     pass
6 | 
7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
8 |     pass
  |
  = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
4 4 | if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101
5 5 |     pass
6 6 | 
7   |-if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool):  # SIM101
  7 |+if isinstance(a, (int, float)) or isinstance(b, bool):  # SIM101
8 8 |     pass
9 9 | 
10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float):  # SIM101

SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
   |
 8 |     pass
 9 | 
10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float):  # SIM101
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
11 |     pass
   |
   = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
7  7  | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool):  # SIM101
8  8  |     pass
9  9  | 
10    |-if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float):  # SIM101
   10 |+if isinstance(b, bool) or isinstance(a, (int, float)):  # SIM101
11 11 |     pass
12 12 | 
13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float):  # SIM101

SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
   |
14 |     pass
15 | 
16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool):  # SIM101
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
17 |     pass
   |
   = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float):  # SIM101
14 14 |     pass
15 15 | 
16    |-if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool):  # SIM101
   16 |+if (isinstance(a, (int, float))) and isinstance(b, bool):  # SIM101
17 17 |     pass
18 18 | 
19 19 | if isinstance(a.b, int) or isinstance(a.b, float):  # SIM101

SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
   |
17 |     pass
18 | 
19 | if isinstance(a.b, int) or isinstance(a.b, float):  # SIM101
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
20 |     pass
   |
   = help: Merge `isinstance` calls

ℹ Unsafe fix
16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool):  # SIM101
17 17 |     pass
18 18 | 
19    |-if isinstance(a.b, int) or isinstance(a.b, float):  # SIM101
   19 |+if isinstance(a.b, (int, float)):  # SIM101
20 20 |     pass
21 21 | 
22 22 | if isinstance(a(), int) or isinstance(a(), float):  # SIM101

SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call
   |
20 |     pass
21 | 
22 | if isinstance(a(), int) or isinstance(a(), float):  # SIM101
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
23 |     pass
   |
   = help: Merge `isinstance` calls

SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
   |
36 |     pass
37 | 
38 | if x or isinstance(a, int) or isinstance(a, float):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
39 |     pass
   |
   = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
35 35 | if isinstance(a, int) or unrelated_condition or isinstance(a, float):
36 36 |     pass
37 37 | 
38    |-if x or isinstance(a, int) or isinstance(a, float):
   38 |+if x or isinstance(a, (int, float)):
39 39 |     pass
40 40 | 
41 41 | if x or y or isinstance(a, int) or isinstance(a, float) or z:

SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
   |
39 |     pass
40 | 
41 | if x or y or isinstance(a, int) or isinstance(a, float) or z:
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
42 |     pass
   |
   = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
38 38 | if x or isinstance(a, int) or isinstance(a, float):
39 39 |     pass
40 40 | 
41    |-if x or y or isinstance(a, int) or isinstance(a, float) or z:
   41 |+if x or y or isinstance(a, (int, float)) or z:
42 42 |     pass
43 43 | 
44 44 | def f():

SIM101.py:53:3: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
   |
52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
53 | if(isinstance(a, int)) or (isinstance(a, float)):
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101
54 |     pass
   |
   = help: Merge `isinstance` calls for `a`

ℹ Unsafe fix
50 50 |         pass
51 51 | 
52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
53    |-if(isinstance(a, int)) or (isinstance(a, float)):
   53 |+if isinstance(a, (int, float)):
54 54 |     pass
