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

Allow trailing ellipsis in typing.TYPE_CHECKING #10413

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

tjkuson
Copy link
Contributor

@tjkuson tjkuson commented Mar 14, 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

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.
@tjkuson tjkuson marked this pull request as ready for review March 14, 2024 21:55
Copy link
Contributor

github-actions bot commented Mar 14, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

// user might be using the type-checking context to declare a stub.
if checker.semantic().in_type_checking_block() {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be down at the in_protocol_or_abstract_method line? (I.e., shouldn't this only apply to ellipses, not stubs?)

@charliermarsh charliermarsh self-requested a review March 15, 2024 03:09
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@charliermarsh charliermarsh added the bug Something isn't working label Mar 15, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) March 15, 2024 03:49
@charliermarsh charliermarsh merged commit 9675e18 into astral-sh:main Mar 15, 2024
17 checks passed
@tjkuson tjkuson deleted the allow-ellipsis-if-type-checking branch March 15, 2024 08:47
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 this pull request may close these issues.

Don't strip an ellipsis (...) from a function's body - this has special meaning to type-checkers
2 participants