---
source: crates/ruff_linter/src/rules/refurb/mod.rs
---
FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
 --> FURB168.py:5:4
  |
3 | # Errors.
4 |
5 | if isinstance(foo, type(None)):
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 |     pass
  |
help: Replace with `is` operator
  |
4 |
  - if isinstance(foo, type(None)):
5 + if foo is None:
6 |     pass
  |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
 --> FURB168.py:8:4
  |
6 |     pass
7 |
8 | if isinstance(foo and bar, type(None)):
  |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9 |     pass
  |
help: Replace with `is` operator
  |
7 |
  - if isinstance(foo and bar, type(None)):
8 + if (foo and bar) is None:
9 |     pass
  |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:11:4
   |
 9 |     pass
10 |
11 | if isinstance(foo, (type(None), type(None), type(None))):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 |     pass
   |
help: Replace with `is` operator
   |
10 |
   - if isinstance(foo, (type(None), type(None), type(None))):
11 + if foo is None:
12 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:14:4
   |
12 |     pass
13 |
14 | if isinstance(foo, type(None)) is True:
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
15 |     pass
   |
help: Replace with `is` operator
   |
13 |
   - if isinstance(foo, type(None)) is True:
14 + if (foo is None) is True:
15 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:17:5
   |
15 |     pass
16 |
17 | if -isinstance(foo, type(None)):
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |     pass
   |
help: Replace with `is` operator
   |
16 |
   - if -isinstance(foo, type(None)):
17 + if -(foo is None):
18 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:20:4
   |
18 |     pass
19 |
20 | if isinstance(foo, None | type(None)):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 |     pass
   |
help: Replace with `is` operator
   |
19 |
   - if isinstance(foo, None | type(None)):
20 + if foo is None:
21 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:23:4
   |
21 |     pass
22 |
23 | if isinstance(foo, type(None) | type(None)):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 |     pass
   |
help: Replace with `is` operator
   |
22 |
   - if isinstance(foo, type(None) | type(None)):
23 + if foo is None:
24 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:27:4
   |
26 | # A bit contrived, but is both technically valid and equivalent to the above.
27 | if isinstance(foo, (type(None) | ((((type(None))))) | ((None | type(None))))):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28 |     pass
   |
help: Replace with `is` operator
   |
26 | # A bit contrived, but is both technically valid and equivalent to the above.
   - if isinstance(foo, (type(None) | ((((type(None))))) | ((None | type(None))))):
27 + if foo is None:
28 |     pass
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:38:4
   |
36 | from typing import Union
37 |
38 | if isinstance(foo, Union[None]):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39 |     ...
   |
help: Replace with `is` operator
   |
37 |
   - if isinstance(foo, Union[None]):
38 + if foo is None:
39 |     ...
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:41:4
   |
39 |     ...
40 |
41 | if isinstance(foo, Union[None, None]):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42 |     ...
   |
help: Replace with `is` operator
   |
40 |
   - if isinstance(foo, Union[None, None]):
41 + if foo is None:
42 |     ...
   |

FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None`
  --> FURB168.py:44:4
   |
42 |     ...
43 |
44 | if isinstance(foo, Union[None, type(None)]):
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45 |     ...
   |
help: Replace with `is` operator
   |
43 |
   - if isinstance(foo, Union[None, type(None)]):
44 + if foo is None:
45 |     ...
   |
