Skip to content

E203 false positives for slices in format strings #10278

@sciyoshi

Description

@sciyoshi

Sample code:

a = f"{1[1 - 2 :]}"
b = 1[1 - 2 :]

When running with ruff --select E203 --preview, the first line triggers E203:

test.py:1:15: E203 [*] Whitespace before ':'
  |
1 | a = f"{1[1 - 2 :]}"
  |               ^ E203
  |
  = help: Remove whitespace before ':'

The same slice on the second line which is outside of a format string does not trigger E203.

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