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

PLE0307 triggers on __str__ that always raises an exception #11016

Closed
ThiefMaster opened this issue Apr 18, 2024 · 0 comments · Fixed by #11017
Closed

PLE0307 triggers on __str__ that always raises an exception #11016

ThiefMaster opened this issue Apr 18, 2024 · 0 comments · Fixed by #11017
Assignees
Labels
bug Something isn't working

Comments

@ThiefMaster
Copy link
Contributor

class PasswordHash:
    def __str__(self):
        raise RuntimeError('This hash cannot be used in a string context')
$ ruff check --isolated --select PLE0307 --preview --no-cache --output-format concise rufftest/ruff_sample.py
rufftest/ruff_sample.py:2:9: PLE0307 `__str__` does not return `str`

It works as expected when raising NotImplementedError, but IMHO any raise-only body should avoid triggering this.

@charliermarsh charliermarsh self-assigned this Apr 18, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Apr 18, 2024
charliermarsh added a commit that referenced this issue Apr 18, 2024
## Summary

If the method always raises, we shouldn't raise a diagnostic for
"returning a value of the wrong type".

Closes #11016.
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