Skip to content

RUF015 auto fix changes behavior #6148

@jc-louis

Description

@jc-louis

Using ruff v0.0.280 with --fix the rule RUF015 changes code behavior:

# before RUF015 auto fix
def fct(a: list, b: list):
    return a + [ele for ele in b if ele][:1]


print(fct([1], [0]))  # [1]


# after RUF015 auto fix
def fct(a: list, b: list):
    return [*a, next(ele for ele in b if ele)]


print(fct([1], [0]))  # raises StopIteration

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions