ruff
f183d34d - [ty] Add opt-in `truthiness-test-of-none-union` rule (#28889)

Commit
16 days ago
[ty] Add opt-in `truthiness-test-of-none-union` rule (#28889) ## Summary Add a new opt-in `truthiness-test-of-none-union ` rule which flags truthiness checks on types like `int | None` or `str | None`. For example, it will emit an error on the following (problematic) `if not limit` check: ```py def take(items: list[str], limit: int | None = None) -> list[str]: if not limit: # error: [truthiness-test-of-none-union] return items return items[:limit] ``` Related to https://github.com/astral-sh/ruff/discussions/8757 and inspired by Pyrefly's `implicit-bool` rule (but narrower in scope). ## Test strategy New test suite
Author
Parents
Loading