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

Detect literals with unary operators (UP018) #10060

Merged
merged 3 commits into from
Feb 20, 2024

Conversation

sanxiyn
Copy link
Contributor

@sanxiyn sanxiyn commented Feb 20, 2024

Fix #10029.

@charliermarsh charliermarsh added the bug Something isn't working label Feb 20, 2024
@charliermarsh charliermarsh self-requested a review February 20, 2024 16:03
Comment on lines 231 to 234
if unary {
if !matches!(literal_type, LiteralType::Int | LiteralType::Float) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind adding a comment why this check is necessary for unary only and add a test case that verifies that ruff early returns if it's an unary and neither an Int nor Float

Copy link
Member

Choose a reason for hiding this comment

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

I moved this up into the match.

@charliermarsh charliermarsh enabled auto-merge (squash) February 20, 2024 18:12
@charliermarsh charliermarsh merged commit 7eafba2 into astral-sh:main Feb 20, 2024
16 checks passed
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

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.

UP018 doesn't detect integers literals used with unary operators
3 participants