Skip to content

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
@github-actions
Copy link
Contributor

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
@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.

2 participants