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

Ruff formatter - unicode string inside of Enum object always lowercasing characters #13859

Closed
DashKenny opened this issue Oct 21, 2024 · 2 comments
Labels
formatter Related to the formatter question Asking for support or clarification

Comments

@DashKenny
Copy link

Hi,

I've been trying to upgrade ruff and use the formatter, so we can remove black. I have noticed this diff when using the formatter:

image

This enum is used to validate codes from an external API, I would rather not try and handle lowercasing that data before accessing this enum. I cannot seem to find a rule to turn off this behaviour, does this not exist or am I missing something? Nothing interesting popped out to me when running ruff format --verbose <path>

Ruff version: 0.7.0

Code snippet:

from enum import Enum


class TestEnum(Enum):
    ANGRY = '\u1F621'
    SAD = '\u1F622'

Ruff pyproject settings:

[tool.ruff.lint]
select = ["E", "F", "I", "Q", "N"]
ignore = []

[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"

[tool.ruff.format]
quote-style = "single"

Command invoked:
ruff format <path> (Doesn't matter if it's only the file, or the whole repo)

@MichaReiser MichaReiser added question Asking for support or clarification formatter Related to the formatter labels Oct 21, 2024
@MichaReiser
Copy link
Member

MichaReiser commented Oct 21, 2024

hi @DashKenny

The casing of the hex-values in unicode escapes doesn't change the value at runtime:

>>> '\u1F621' == '\u1f621'
True

It's just a different way to format the same data.

@DashKenny
Copy link
Author

Thanks for the quick reply @MichaReiser and pointing that out. That makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

2 participants