---
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
---
SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
 --> SIM101.py:1:4
  |
1 | if isinstance(a, int) or isinstance(a, float):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 |     pass
  |
help: Merge `isinstance` calls for `a`
  |
  - if isinstance(a, int) or isinstance(a, float):  # SIM101
1 + if isinstance(a, (int, float)):  # SIM101
2 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
 --> SIM101.py:4:4
  |
2 |     pass
3 |
4 | if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 |     pass
  |
help: Merge `isinstance` calls for `a`
  |
3 |
  - if isinstance(a, (int, float)) or isinstance(a, bool):  # SIM101
4 + if isinstance(a, (int, float, bool)):  # SIM101
5 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
 --> SIM101.py:7:4
  |
5 |     pass
6 |
7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool):  # SIM101
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 |     pass
  |
help: Merge `isinstance` calls for `a`
  |
6 |
  - 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 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  --> SIM101.py:10:4
   |
 8 |     pass
 9 |
10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float):  # SIM101
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 |     pass
   |
help: Merge `isinstance` calls for `a`
   |
9  |
   - 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 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  --> SIM101.py:16:5
   |
14 |     pass
15 |
16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool):  # SIM101
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 |     pass
   |
help: Merge `isinstance` calls for `a`
   |
15 |
   - 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 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
  --> SIM101.py:19:4
   |
17 |     pass
18 |
19 | if isinstance(a.b, int) or isinstance(a.b, float):  # SIM101
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 |     pass
   |
help: Merge `isinstance` calls
   |
18 |
   - if isinstance(a.b, int) or isinstance(a.b, float):  # SIM101
19 + if isinstance(a.b, (int, float)):  # SIM101
20 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

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

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  --> SIM101.py:38:4
   |
36 |     pass
37 |
38 | if x or isinstance(a, int) or isinstance(a, float):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39 |     pass
   |
help: Merge `isinstance` calls for `a`
   |
37 |
   - if x or isinstance(a, int) or isinstance(a, float):
38 + if x or isinstance(a, (int, float)):
39 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  --> SIM101.py:41:4
   |
39 |     pass
40 |
41 | if x or y or isinstance(a, int) or isinstance(a, float) or z:
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42 |     pass
   |
help: Merge `isinstance` calls for `a`
   |
40 |
   - 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 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call
  --> SIM101.py:53:3
   |
52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
53 | if(isinstance(a, int)) or (isinstance(a, float)):
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
54 |     pass
   |
help: Merge `isinstance` calls for `a`
   |
52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
   - if(isinstance(a, int)) or (isinstance(a, float)):
53 + if isinstance(a, (int, float)):
54 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
  --> SIM101.py:60:1
   |
58 | # the AST mangles f-strings whose format spec contains escape sequences or
59 | # whose interpolations include lambdas.
60 | isinstance(f"{(lambda: 0)}", int) or isinstance(f"{(lambda: 0)}", str)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
   |
help: Merge `isinstance` calls
   |
59 | # whose interpolations include lambdas.
   - isinstance(f"{(lambda: 0)}", int) or isinstance(f"{(lambda: 0)}", str)
60 + isinstance(f"{(lambda: 0)}", (int, str))
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
  --> SIM101.py:61:1
   |
59 | # whose interpolations include lambdas.
60 | isinstance(f"{(lambda: 0)}", int) or isinstance(f"{(lambda: 0)}", str)
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
63 | isinstance(f"{0:\x7b}", int) or isinstance(f"{0:\x7b}", str)
   |
help: Merge `isinstance` calls
   |
60 | isinstance(f"{(lambda: 0)}", int) or isinstance(f"{(lambda: 0)}", str)
   - isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
61 + isinstance(f"{0:{(lambda: 0)}}", (int, str))
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
  --> SIM101.py:62:1
   |
60 | isinstance(f"{(lambda: 0)}", int) or isinstance(f"{(lambda: 0)}", str)
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 | isinstance(f"{0:\x7b}", int) or isinstance(f"{0:\x7b}", str)
   |
help: Merge `isinstance` calls
   |
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
   - isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
62 + isinstance(f"{0:\x22}", (int, str))
63 | isinstance(f"{0:\x7b}", int) or isinstance(f"{0:\x7b}", str)
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call
  --> SIM101.py:63:1
   |
61 | isinstance(f"{0:{(lambda: 0)}}", int) or isinstance(f"{0:{(lambda: 0)}}", str)
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
63 | isinstance(f"{0:\x7b}", int) or isinstance(f"{0:\x7b}", str)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64 |
65 | # Regression test for: https://github.com/astral-sh/ruff/pull/25061
   |
help: Merge `isinstance` calls
   |
62 | isinstance(f"{0:\x22}", int) or isinstance(f"{0:\x22}", str)
   - isinstance(f"{0:\x7b}", int) or isinstance(f"{0:\x7b}", str)
63 + isinstance(f"{0:\x7b}", (int, str))
64 |
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:67:1
   |
65 | # Regression test for: https://github.com/astral-sh/ruff/pull/25061
66 | types = (int,)
67 | isinstance(x, (*types,)) or isinstance(x, ())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
69 | isinstance(x, ()) or isinstance(x, int)
   |
help: Merge `isinstance` calls for `x`
   |
66 | types = (int,)
   - isinstance(x, (*types,)) or isinstance(x, ())
67 + isinstance(x, (*types,))
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:68:1
   |
66 | types = (int,)
67 | isinstance(x, (*types,)) or isinstance(x, ())
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69 | isinstance(x, ()) or isinstance(x, int)
70 | isinstance(x, ()) or isinstance(x, ())
   |
help: Merge `isinstance` calls for `x`
   |
67 | isinstance(x, (*types,)) or isinstance(x, ())
   - isinstance(x, (*types,)) or isinstance(x, (*types,))
68 + isinstance(x, (*types, *types))
69 | isinstance(x, ()) or isinstance(x, int)
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:69:1
   |
67 | isinstance(x, (*types,)) or isinstance(x, ())
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
69 | isinstance(x, ()) or isinstance(x, int)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70 | isinstance(x, ()) or isinstance(x, ())
71 | ((isinstance(x, int)) or isinstance(x, str))
   |
help: Merge `isinstance` calls for `x`
   |
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
   - isinstance(x, ()) or isinstance(x, int)
69 + isinstance(x, (int))
70 | isinstance(x, ()) or isinstance(x, ())
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:70:1
   |
68 | isinstance(x, (*types,)) or isinstance(x, (*types,))
69 | isinstance(x, ()) or isinstance(x, int)
70 | isinstance(x, ()) or isinstance(x, ())
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71 | ((isinstance(x, int)) or isinstance(x, str))
72 | isinstance(x, int) or (isinstance(x, str))
   |
help: Merge `isinstance` calls for `x`
   |
69 | isinstance(x, ()) or isinstance(x, int)
   - isinstance(x, ()) or isinstance(x, ())
70 + isinstance(x, ())
71 | ((isinstance(x, int)) or isinstance(x, str))
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:71:2
   |
69 | isinstance(x, ()) or isinstance(x, int)
70 | isinstance(x, ()) or isinstance(x, ())
71 | ((isinstance(x, int)) or isinstance(x, str))
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72 | isinstance(x, int) or (isinstance(x, str))
   |
help: Merge `isinstance` calls for `x`
   |
70 | isinstance(x, ()) or isinstance(x, ())
   - ((isinstance(x, int)) or isinstance(x, str))
71 + (isinstance(x, (int, str)))
72 | isinstance(x, int) or (isinstance(x, str))
   |
note: This is an unsafe fix and may change runtime behavior

SIM101 [*] Multiple `isinstance` calls for `x`, merge into a single call
  --> SIM101.py:72:1
   |
70 | isinstance(x, ()) or isinstance(x, ())
71 | ((isinstance(x, int)) or isinstance(x, str))
72 | isinstance(x, int) or (isinstance(x, str))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: Merge `isinstance` calls for `x`
   |
71 | ((isinstance(x, int)) or isinstance(x, str))
   - isinstance(x, int) or (isinstance(x, str))
72 + isinstance(x, (int, str))
   |
note: This is an unsafe fix and may change runtime behavior
