---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
repeated_isinstance_calls.py:15:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[3], float | int)`
   |
14 |     # not merged
15 |     if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True:  # [consider-merging-isinstance]
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
16 |         pass
17 |     result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
   |
   = help: Replace with `isinstance(var[3], float | int)`

ℹ Safe fix
12 12 |     result = isinstance(var[2], (int, float))
13 13 | 
14 14 |     # not merged
15    |-    if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True:  # [consider-merging-isinstance]
   15 |+    if isinstance(var[3], float | int):  # [consider-merging-isinstance]
16 16 |         pass
17 17 |     result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
18 18 | 

repeated_isinstance_calls.py:17:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[4], float | int)`
   |
15 |     if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True:  # [consider-merging-isinstance]
16 |         pass
17 |     result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
18 | 
19 |     result = isinstance(var[5], int) or True or isinstance(var[5], float)  # [consider-merging-isinstance]
   |
   = help: Replace with `isinstance(var[4], float | int)`

ℹ Safe fix
14 14 |     # not merged
15 15 |     if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True:  # [consider-merging-isinstance]
16 16 |         pass
17    |-    result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
   17 |+    result = isinstance(var[4], float | int)  # [consider-merging-isinstance]
18 18 | 
19 19 |     result = isinstance(var[5], int) or True or isinstance(var[5], float)  # [consider-merging-isinstance]
20 20 | 

repeated_isinstance_calls.py:19:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[5], float | int)`
   |
17 |     result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
18 | 
19 |     result = isinstance(var[5], int) or True or isinstance(var[5], float)  # [consider-merging-isinstance]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
20 | 
21 |     inferred_isinstance = isinstance
   |
   = help: Replace with `isinstance(var[5], float | int)`

ℹ Safe fix
16 16 |         pass
17 17 |     result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False  # [consider-merging-isinstance]
18 18 | 
19    |-    result = isinstance(var[5], int) or True or isinstance(var[5], float)  # [consider-merging-isinstance]
   19 |+    result = isinstance(var[5], float | int)  # [consider-merging-isinstance]
20 20 | 
21 21 |     inferred_isinstance = isinstance
22 22 |     result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False   # [consider-merging-isinstance]

repeated_isinstance_calls.py:23:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[10], list | str)`
   |
21 |     inferred_isinstance = isinstance
22 |     result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False   # [consider-merging-isinstance]
23 |     result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list)   # [consider-merging-isinstance]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
24 |     result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float)   # [consider-merging-isinstance]
   |
   = help: Replace with `isinstance(var[10], list | str)`

ℹ Safe fix
20 20 | 
21 21 |     inferred_isinstance = isinstance
22 22 |     result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False   # [consider-merging-isinstance]
23    |-    result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list)   # [consider-merging-isinstance]
   23 |+    result = isinstance(var[10], list | str)   # [consider-merging-isinstance]
24 24 |     result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float)   # [consider-merging-isinstance]
25 25 | 
26 26 |     result = isinstance(var[20])

repeated_isinstance_calls.py:24:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[11], float | int)`
   |
22 |     result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False   # [consider-merging-isinstance]
23 |     result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list)   # [consider-merging-isinstance]
24 |     result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float)   # [consider-merging-isinstance]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
25 | 
26 |     result = isinstance(var[20])
   |
   = help: Replace with `isinstance(var[11], float | int)`

ℹ Safe fix
21 21 |     inferred_isinstance = isinstance
22 22 |     result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False   # [consider-merging-isinstance]
23 23 |     result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list)   # [consider-merging-isinstance]
24    |-    result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float)   # [consider-merging-isinstance]
   24 |+    result = isinstance(var[11], float | int)   # [consider-merging-isinstance]
25 25 | 
26 26 |     result = isinstance(var[20])
27 27 |     result = isinstance()

repeated_isinstance_calls.py:30:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[12], float | int | list)`
   |
29 |     # Combination merged and not merged
30 |     result = isinstance(var[12], (int, float)) or isinstance(var[12], list)  # [consider-merging-isinstance]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
31 | 
32 |     # not merged but valid
   |
   = help: Replace with `isinstance(var[12], float | int | list)`

ℹ Safe fix
27 27 |     result = isinstance()
28 28 | 
29 29 |     # Combination merged and not merged
30    |-    result = isinstance(var[12], (int, float)) or isinstance(var[12], list)  # [consider-merging-isinstance]
   30 |+    result = isinstance(var[12], float | int | list)  # [consider-merging-isinstance]
31 31 | 
32 32 |     # not merged but valid
33 33 |     result = isinstance(var[5], int) and var[5] * 14 or isinstance(var[5], float) and var[5] * 14.4

repeated_isinstance_calls.py:42:3: PLR1701 [*] Merge `isinstance` calls: `isinstance(self.k, float | int)`
   |
41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
42 | if(isinstance(self.k, int)) or (isinstance(self.k, float)):
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701
43 |     ...
   |
   = help: Replace with `isinstance(self.k, float | int)`

ℹ Safe fix
39 39 | 
40 40 | 
41 41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483
42    |-if(isinstance(self.k, int)) or (isinstance(self.k, float)):
   42 |+if isinstance(self.k, float | int):
43 43 |     ...


