[red-knot] Diagnostics for incorrect bool usages (#16238)

This commit is contained in:
Micha Reiser
2025-02-21 18:26:05 +00:00
committed by GitHub
parent 3aa7ba31b1
commit 5fab97f1ef
28 changed files with 1267 additions and 260 deletions

View File

@@ -351,6 +351,20 @@ class Y(Foo): ...
reveal_type(X() + Y()) # revealed: int
```
## Operations involving types with invalid `__bool__` methods
<!-- snapshot-diagnostics -->
```py
class NotBoolable:
__bool__ = 3
a = NotBoolable()
# error: [unsupported-bool-conversion]
10 and a and True
```
## Unsupported
### Dunder as instance attribute