-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't strip an ellipsis (...
) from a function's body - this has special meaning to type-checkers
#10358
Labels
rule
Implementing or modifying a lint rule
Comments
Hm we talked about this previously re protocols
Should we make another exception for |
That would be good. Treating |
This should be relatively easy if someone is interested in it. |
charliermarsh
pushed a commit
that referenced
this issue
Mar 15, 2024
## Summary Trailing ellipses in objects defined in `typing.TYPE_CHECKING` might be meaningful (it might be declaring a stub). Thus, we should skip the `unnecessary-placeholder` (`PIE970`) rule in such contexts. Closes #10358. ## Test Plan `cargo nextest run`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before
ruff
:After
ruff
:The ellipses signals to the type-checker (e.g. pyright) that function is acting as a stub and the body should be ignored. In the latter case, the type-checker thinks that the function returns
None
and thus marks the return-type as an error.I.e. without the ellipses, you have to either: provide a fake function body or
# type: ignore
the function's signature, which would mask actual type-errors in the signature.The text was updated successfully, but these errors were encountered: