Detect non-empty loops
Open
enhancement request
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
Some loops are clearly executed at least once because they iterate over a non-empty constant. (Or a non-empty typed tuple.)
```python
for x in "a":
y=123
del y
```
```
$ pyright /tmp/tr.py
/tmp/tr.py
/tmp/tr.py:3:5 - error: "y" is possibly unbound (reportPossiblyUnboundVariable)
```
No, it's not.
Contributor guide
Research direction
Start by reproducing the issue with the Python snippet in the report and trace Pyright's analysis of the non-empty loop and the later `del y`. Done means Pyright no longer reports `y` as possibly unbound when the loop iterates over a known non-empty constant or typed tuple.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100