Skip to content

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

@DashKenny

Description

@DashKenny

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterquestionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions