• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

psf / black / 24340184094 / 1
96%
master: 96%

Build:
Build:
LAST BUILD BRANCH: fix-fmt-skip-class-header
DEFAULT BRANCH: master
Ran 13 Apr 2026 11:13AM UTC
Files 43
Run time 3s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

13 Apr 2026 11:09AM UTC coverage: 95.631% (-0.02%) from 95.651%
24340184094.1

push

github

web-flow
Fix crash when f-string follows # fmt: off inside brackets (#5097)

* Fix crash when f-string follows # fmt: off inside brackets (#4511)

When an f-string appeared after a `# fmt: off` comment inside brackets,
Black would crash with an AssertionError about invalid string prefix
characters.

The root cause: `normalize_fmt_off` (which runs before line generation)
converts content between `# fmt: off` and `# fmt: on` into
STANDALONE_COMMENT nodes. When this content is inside an f-string node,
the f-string's children get replaced with a STANDALONE_COMMENT leaf.
However, `visit_fstring` still tried to call `fstring_tstring_to_string`
on the modified node, producing a "string" value like
`# fmt: off\nf"""\n"""` which fails the string prefix assertion.

The fix adds a guard in `visit_fstring` (and `visit_tstring`) to detect
when the node has been modified by `normalize_fmt_off` and fall back to
`visit_default` instead of attempting the f-string-to-string conversion.

Fixes #4511.

* Add unindented test cases for f-string with # fmt: off inside brackets

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add changelog entry for f-string fmt: off crash fix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

3993 of 4318 branches covered (92.47%)

8339 of 8720 relevant lines covered (95.63%)

0.96 hits per line

Source Files on job py3.13-ubuntu-latest - 24340184094.1
  • Tree
  • List 43
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 24340184094
  • fc33c250 on github
  • Prev Job for on main (#24321958736.2)
  • Next Job for on main (#24381667833.2)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc