Rule suggestion: lint against the use of `in` with compound comparisons
- Dominant language
- Rust
- Stars
- 49.6k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
The use of `in` with compound comparisons often leads to unintended/surprising behaviour.
```python
False == False in [False] # True
```
A solution would be to use parentheses.
```python
(False == False) in [False] # False
False == (False in [False]) # False
```
Similar to #8721, but the AST produced by `False or False and False` is quite different, so might be a different rule.
Contributor guide
Research direction
Start by reviewing issue #8721 and comparing the AST for compound comparisons with the examples shown here. Define the rule around surprising uses of `in` with compound comparisons, require parentheses as the remedy, and verify that the examples produce the intended diagnostics without overlapping the existing rule.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100