astral-sh / astral-sh/ruff

SIM115 open() inside a return statement not reported

Open
#25,916 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

### Summary

SIM115 fails to detect open() when it appears inside a return statement:

```
def not_detected():
return [x for x in open("a")]
```

```
def detected():
result = [x for x in open("a")]
```

### Version

ruff 0.15.17

Contributor guide

Open the contributing guide

Research direction

Start by running Ruff against the two Python examples and locating the SIM115 rule implementation and its existing tests. Add a regression case for the list comprehension inside a return statement, then verify that both examples are handled consistently without changing the existing detection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.