Skip to content

--fix --unsafe-fixes that converts lambda to function (rule E731) removes underscores from numbers. #10277

@dwreeves

Description

@dwreeves

Minimal reproduction:

echo 'at_least_one_million = lambda _: _ >= 1_000_000' > foo.py
ruff foo.py --unsafe-fixes --fix
cat foo.py

File:

at_least_one_million = lambda _: _ >= 1_000_000

After fix:

def at_least_one_million(_):
    return _ >= 1000000

Expected behavior was that it would preserve my underscores (unless another linting rule disables underscores in the number), i.e. something like this:

def at_least_one_million(_):
    return _ >= 1_000_000

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violationsparserRelated to the parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions