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

Fix bug where PLE1307 was raised when formatting %c with characters #8407

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Nov 1, 2023

Closes #8406

Copy link
Contributor

github-actions bot commented Nov 1, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@zanieb zanieb requested a review from charliermarsh November 1, 2023 16:44
@zanieb zanieb added the bug Something isn't working label Nov 1, 2023
ResolvedPythonType::Atom(atom) => {
// Special case where `%c` allows single character strings to be formatted
if format.format_char == 'c' {
if let Expr::StringLiteral(string) = value {
Copy link
Member

Choose a reason for hiding this comment

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

Could this also be a byte string or fstring?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm good idea, I checked:

print("%c" % b"x") # Runtime error
print("%c" % f"x")  # OK

I'm hesitant to support the format string though it's a weird use.

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
@zanieb zanieb enabled auto-merge (squash) November 2, 2023 04:29
@zanieb zanieb merged commit a8a7230 into main Nov 2, 2023
16 checks passed
@zanieb zanieb deleted the zanie/ple-char branch November 2, 2023 04:36
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.

PLE1307: false positive
3 participants