Skip to content

[Autofix error] RUF005 autofix fails inside f-string: f"{a() + ['b']}" #4324

@konstin

Description

@konstin

In ruff 99a755f, the following snippet causes the autofix RUF005 to introduce a syntax error:

f"{a() + ['b']}"
$ ./ruff --no-cache --select RUF005 --fix code.py

error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in `ruff`. If you could open an issue at:

    https://github.com/charliermarsh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `code.py`, the rule codes RUF005, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

code.py:1:4: RUF005 Consider `[*a(), "b"]` instead of concatenation
Found 1 error.

This was originally discovered in https://github.com/Mojino01/hugging_face/blob/3dae0d7b4fb8d7e9383b893e4e1799191bb2ab7b/src/transformers/pipelines/base.py#L1181

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions