Skip to content

Unexpected E201 when embedding an object literal into an f-string #2002

@rijenkii

Description

@rijenkii

how did you install flake8?

> pip install flake8
Looking in indexes: https://pypi.org/simple, https://__token__:****@git.etude.team/api/packages/etude/pypi/simple
Collecting flake8
  Using cached flake8-7.3.0-py2.py3-none-any.whl.metadata (3.8 kB)
Collecting mccabe<0.8.0,>=0.7.0 (from flake8)
  Using cached mccabe-0.7.0-py2.py3-none-any.whl.metadata (5.0 kB)
Collecting pycodestyle<2.15.0,>=2.14.0 (from flake8)
  Using cached pycodestyle-2.14.0-py2.py3-none-any.whl.metadata (4.5 kB)
Collecting pyflakes<3.5.0,>=3.4.0 (from flake8)
  Using cached pyflakes-3.4.0-py2.py3-none-any.whl.metadata (3.5 kB)
Using cached flake8-7.3.0-py2.py3-none-any.whl (57 kB)
Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB)
Using cached pycodestyle-2.14.0-py2.py3-none-any.whl (31 kB)
Using cached pyflakes-3.4.0-py2.py3-none-any.whl (63 kB)
Installing collected packages: pyflakes, pycodestyle, mccabe, flake8
Successfully installed flake8-7.3.0 mccabe-0.7.0 pycodestyle-2.14.0 pyflakes-3.4.0

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.13.5",
    "system": "Linux"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.14.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.4.0"
    }
  ],
  "version": "7.3.0"
}

describe the problem

what I expected to happen

Expected the following code to not trigger any linting errors, as I see no possible way of writing the code without adding a space after the first { (or extracting the object literal into a variable)

sample code

print(f"here is an object: { {"hello": "world"}}")

commands ran

> flake8 t.py
t.py:1:29: E201 whitespace after '{'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions