Black: `# fmt: off` / `# fmt: on` handling

Created on 14 Mar 2018  路  2Comments  路  Source: psf/black

This is documented but not actually implemented yet.

enhancement

Most helpful comment

@joslarson tl;dr - Explicit is better than implicit.

What you're suggesting sounds intriguing but I would need to implement # yapf: disable and # yapf: enable anyway. So # fmt: off and # fmt: on it is for the time being. That makes it obvious where you want the auto-formatting to resume. If people put those in strange places, that won't be fun to debug but I'm prepared to deal with this.

We might switch to a single # fmt: ignore if the current approach proves to be too flaky.

All 2 comments

@ambv what do you think about doing this the way prettier does instead (or as well), where you only need a single comment to disable formatting on an entire block/node: https://prettier.io/docs/en/ignore.html

# fmt: ignore
hey = {
    "don't": 'touch', 'my': 'ugly', 'formatting',
   'because': ['I', "don't", 'know', 'any', 'better']}

I think fmt off/fmt: on would still be useful, but I think ignoring by AST node would be the most common use case.

@joslarson tl;dr - Explicit is better than implicit.

What you're suggesting sounds intriguing but I would need to implement # yapf: disable and # yapf: enable anyway. So # fmt: off and # fmt: on it is for the time being. That makes it obvious where you want the auto-formatting to resume. If people put those in strange places, that won't be fun to debug but I'm prepared to deal with this.

We might switch to a single # fmt: ignore if the current approach proves to be too flaky.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Curly-Mo picture Curly-Mo  路  3Comments

dgnsrekt picture dgnsrekt  路  3Comments

asottile picture asottile  路  3Comments

decibyte picture decibyte  路  3Comments

testvinder picture testvinder  路  3Comments