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

psf / black / 24340184094
96%
master: 96%

Build:
Build:
LAST BUILD BRANCH: test-on-315
DEFAULT BRANCH: master
Ran 13 Apr 2026 11:10AM UTC
Jobs 5
Files 43
Run time 1min
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.665% (-0.02%) from 95.685%
24340184094

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>

5535 of 5857 branches covered (94.5%)

4 of 6 new or added lines in 1 file covered. (66.67%)

8342 of 8720 relevant lines covered (95.67%)

4.78 hits per line

Uncovered Changes

Lines Coverage ∆ File
2
96.42
-0.21% src/black/linegen.py
Jobs
ID Job ID Ran Files Coverage
1 py3.13-ubuntu-latest - 24340184094.1 13 Apr 2026 11:13AM UTC 43
95.63
2 py3.11-ubuntu-latest - 24340184094.2 13 Apr 2026 11:13AM UTC 43
95.62
3 py3.12.10-ubuntu-latest - 24340184094.3 13 Apr 2026 11:13AM UTC 43
95.63
4 py3.10-ubuntu-latest - 24340184094.4 13 Apr 2026 11:13AM UTC 43
95.61
5 py3.14-ubuntu-latest - 24340184094.5 13 Apr 2026 11:13AM UTC 43
95.16
Source Files on build 24340184094
  • 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 Repo
  • fc33c250 on github
  • Prev Build on main (#24321958736)
  • Next Build on main (#24381667833)
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