Skip to content

Spurious E231 for nested format substitutions #1241

Open

Description

@anntzer

For

x = 1
digits = 1
print(f"{x:0.{digits:d}f}")  # admittedly the :d is not needed in this minimal repro, but still valid.

pycodestyle 2.11.1 spuriously complains about a missing whitespace after the second colon in the f-string:

test.py:3:21: E231 missing whitespace after ':'

Activity

  1. PNHD commented on Aug 31, 2026

    @PNHD

    Hi! I have a tested fix for this issue ready in my fork:
    PNHD/pycodestyle:fix/1241-nested-fstring-format

    The repository currently limits pull-request creation to collaborators, so I'm unable to open the PR myself.

    The fix has been verified with the full upstream GitHub Actions matrix, tox, flake8, and pre-commit. It also includes regression coverage for the reported nested format-specifier case.

    If you'd like, could you enable me to submit the PR or let me know the preferred contribution path?

  2. asottile commented on Aug 31, 2026

    @asottile
    Member

    we don't accept ai slop contributions

  3. inchang-ing commented on Oct 22, 2026

    @inchang-ing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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