---
source: crates/red_knot_test/src/lib.rs
expression: snapshot
---
---
mdtest name: rich_comparison.md - Comparison: Rich Comparison - Chained comparisons with objects that don't implement `__bool__` correctly
mdtest path: crates/red_knot_python_semantic/resources/mdtest/comparison/instances/rich_comparison.md
---

# Python source files

## mdtest_snippet.py

```
 1 | class NotBoolable:
 2 |     __bool__: int = 3
 3 | 
 4 | class Comparable:
 5 |     def __lt__(self, item) -> NotBoolable:
 6 |         return NotBoolable()
 7 | 
 8 |     def __gt__(self, item) -> NotBoolable:
 9 |         return NotBoolable()
10 | 
11 | # error: [unsupported-bool-conversion]
12 | 10 < Comparable() < 20
13 | # error: [unsupported-bool-conversion]
14 | 10 < Comparable() < Comparable()
15 | 
16 | Comparable() < Comparable()  # fine
```

# Diagnostics

```
error: lint:unsupported-bool-conversion
  --> /src/mdtest_snippet.py:12:1
   |
11 | # error: [unsupported-bool-conversion]
12 | 10 < Comparable() < 20
   | ^^^^^^^^^^^^^^^^^ Boolean conversion is unsupported for type `NotBoolable`; its `__bool__` method isn't callable
13 | # error: [unsupported-bool-conversion]
14 | 10 < Comparable() < Comparable()
   |

```

```
error: lint:unsupported-bool-conversion
  --> /src/mdtest_snippet.py:14:1
   |
12 | 10 < Comparable() < 20
13 | # error: [unsupported-bool-conversion]
14 | 10 < Comparable() < Comparable()
   | ^^^^^^^^^^^^^^^^^ Boolean conversion is unsupported for type `NotBoolable`; its `__bool__` method isn't callable
15 |
16 | Comparable() < Comparable()  # fine
   |

```
