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

Avoid incorrect tuple transformation in single-element case (C409) #10491

Conversation

WindowGenerator
Copy link
Contributor

Summary

Fixed: incorrect rule transformation rule C409 with single element.

Test Plan

Added examples from #10323 to test fixtures.

@WindowGenerator WindowGenerator force-pushed the fix-unnecessary-literal-within-tuple-call branch from 1b83088 to 41107a8 Compare March 20, 2024 16:35
Copy link

github-actions bot commented Mar 20, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

// Replace [1, 2] -> (1, 2) or [1] -> (1,)
let tuple: String = if let [elt] = elts.as_slice() {
let elt: &str = checker.locator().slice(elt);
format!("({elt},)")
Copy link
Member

Choose a reason for hiding this comment

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

This is going to lose the spacing around the element. Can you take a look at how we solved this in #10461?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for suggestion!

@WindowGenerator WindowGenerator force-pushed the fix-unnecessary-literal-within-tuple-call branch from 41107a8 to 81b8b3a Compare March 20, 2024 19:35
@charliermarsh charliermarsh self-requested a review March 20, 2024 20:28
@charliermarsh charliermarsh self-assigned this Mar 20, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Mar 20, 2024
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 changed the title Fixed: incorrect rule transformation rule C409 with single element Avoid incorrect tuple transformation in single-element case (C409) Mar 21, 2024
@charliermarsh charliermarsh enabled auto-merge (squash) March 21, 2024 00:01
@charliermarsh charliermarsh merged commit 4045df4 into astral-sh:main Mar 21, 2024
17 checks passed
@WindowGenerator WindowGenerator deleted the fix-unnecessary-literal-within-tuple-call branch March 22, 2024 07:11
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.

None yet

2 participants