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

Autofix for ANN 201 incorrectly adds None Return Type #9201

Closed
max-muoto opened this issue Dec 19, 2023 · 2 comments · Fixed by #9206
Closed

Autofix for ANN 201 incorrectly adds None Return Type #9201

max-muoto opened this issue Dec 19, 2023 · 2 comments · Fixed by #9206
Labels
bug Something isn't working

Comments

@max-muoto
Copy link
Contributor

Let's say we have a function that has no ability to return:

def foo():
    raise ValueError

The correct return type for this would be NoReturn. However, the autofix for ANN 201, adds None here as the return type instead.

Ruff Version: 0.1.8
Command: ruff check . --fix --unsafe-fixes.

@charliermarsh
Copy link
Member

Nice, makes sense. Thank you!

@charliermarsh charliermarsh added the bug Something isn't working label Dec 19, 2023
charliermarsh added a commit that referenced this issue Dec 20, 2023
## Summary

Given a function like:

```python
def func(x: int):
    if not x:
        raise ValueError
    else:
        raise TypeError
```

We now correctly use `NoReturn` as the return type, rather than `None`.

Closes #9201.
@max-muoto
Copy link
Contributor Author

Thanks @charliermarsh! Really appreciate the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants