Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM103 should detect implicit else #10402

Closed
charliermarsh opened this issue Mar 14, 2024 · 2 comments · Fixed by #10414
Closed

SIM103 should detect implicit else #10402

charliermarsh opened this issue Mar 14, 2024 · 2 comments · Fixed by #10414
Assignees
Labels
good first issue Good for newcomers rule Implementing or modifying a lint rule

Comments

@charliermarsh
Copy link
Member

See: https://github.com/sbdchd/flake8-pie#pie801-prefer-simple-return.

In that example:

# error
def main():
    if foo > 5:
        return True
    return False

# error
def main():
    if foo > 5:
        return True
    else:
        return False

# ok
def main():
    return foo > 5

We catch the second case, but not the first.

@charliermarsh charliermarsh added good first issue Good for newcomers rule Implementing or modifying a lint rule labels Mar 14, 2024
@ottaviohartman
Copy link
Contributor

@charliermarsh I'd like to give this a shot.

@charliermarsh
Copy link
Member Author

Great!

charliermarsh pushed a commit that referenced this issue Mar 18, 2024
…`SIM103`) (#10414)

Fixes #10402 

## Summary

For SIM103, detect and simplify the following case:

[playground
link](https://play.ruff.rs/d98570aa-b180-495b-8600-5c4c3fd02526)
```python
def main():
    if foo > 5:
        return True
    return False
```

## Test Plan

Unit tested only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants