Skip to content

[pyupgrade] Clarify default encoding argument handling (UP012) - #27315

Merged
ntBre merged 6 commits into
astral-sh:mainfrom
Whning0513:fix/26854-up012-encoding-arguments
Aug 28, 2026
Merged

ntBre merged 6 commits into
astral-sh:mainfrom
Whning0513:fix/26854-up012-encoding-arguments

Conversation

@Whning0513

Copy link
Copy Markdown
Contributor

Hi! This updates UP012 documentation to describe both supported cases: replacing ASCII literals with bytes literals and removing redundant explicit UTF-8 encoding arguments. It also handles the latter for general expressions such as str(exc).encode("utf-8"), which the rule previously skipped.

Fixes #26854

Copilot AI review requested due to automatic review settings July 29, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, but I don't quite understand the changes here. The issue is labeled documentation Improvements or additions to public-facing documentation , so I wasn't expecting to see any code changes. The new function also seems to be duplicated, and there are no tests demonstrating any changed behavior, if it is warranted.

If you're using AI, please make sure to follow our AI Policy, or your contributions will be closed.

@ntBre ntBre added the documentation Improvements or additions to public-facing documentation label Aug 28, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@ntBre ntBre changed the title UP012: clarify and extend UTF-8 argument handling [pyupgrade] Clarify default encoding argument handling (UP012) Aug 28, 2026
@ntBre
ntBre enabled auto-merge (squash) August 28, 2026 19:45
@ntBre
ntBre disabled auto-merge August 28, 2026 19:46
@ntBre ntBre closed this Aug 28, 2026
@ntBre ntBre reopened this Aug 28, 2026
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre August 28, 2026 19:46
@ntBre
ntBre enabled auto-merge (squash) August 28, 2026 19:47
@ntBre
ntBre merged commit 78e34fd into astral-sh:main Aug 28, 2026
84 of 95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UP012: Description does not match website documentation, and some cases are missed

3 participants