Fix a crash when a colon line is marked between # fmt: off and # fmt: on by yilei · Pull Request #3439 · psf/black (original) (raw)

@yilei

Description

Fixes #3436.

Note that the # fmt: on line is always normalized to the next statement so its indentation is moved in this case. This isn't ideal, but at least it shouldn't crash.

Checklist - did you ...

@yilei

@github-actions

ichard26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should write developer docs on how fmt: off/on/skip work. The logic is already complicated as-is and the edge cases are incredibly confusing sometimes...

Also technically this is invalid use of # fmt: off/on but this is just a limitation of Black since there's no way to represent a # fmt: on at the right indent level right between indention levels.

@ichard26

Oh where are my manners?... Thank you very much for investigating and filing a PR, it's appreciated! 🖤

@yilei

JelleZijlstra

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})