Skip to content

[pyupgrade] Fix UP032 conversion for decimal ints with underscores#21022

Merged
ntBre merged 1 commit into
astral-sh:mainfrom
TaKO8Ki:fix-up032-decimal-underscores
Oct 22, 2025
Merged

[pyupgrade] Fix UP032 conversion for decimal ints with underscores#21022
ntBre merged 1 commit into
astral-sh:mainfrom
TaKO8Ki:fix-up032-decimal-underscores

Conversation

@TaKO8Ki
Copy link
Copy Markdown
Contributor

@TaKO8Ki TaKO8Ki commented Oct 21, 2025

Summary

Fixes #21017

Taught UP032’s parenthesize check to ignore underscores when inspecting decimal integer literals so the converter emits f"{(1_2).real}" instead of invalid syntax.

Test Plan

Added test cases to UP032_2.py.

@github-actions
Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@amyreese amyreese added bug Something isn't working rule Implementing or modifying a lint rule fixes Related to suggested fixes for violations and removed rule Implementing or modifying a lint rule labels Oct 22, 2025
@amyreese amyreese requested a review from ntBre October 22, 2025 02:07
Copy link
Copy Markdown
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

Thank you!

@ntBre ntBre merged commit 6c18f18 into astral-sh:main Oct 22, 2025
40 checks passed
@ntBre ntBre changed the title [ruff] Fix UP032 conversion for decimal ints with underscores [pyupgrade] Fix UP032 conversion for decimal ints with underscores Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UP032 fix doesn’t account for underscores in decimal int literals

3 participants