Say I'd like to format my code like so:
v = (
foo_dict
.setdefault("a", {})
.setdefault("b", {})
.setdefault("c", {})
.setdefault("d", {})
.setdefault("e", {})
)
Black will of course reformat this to put foo_dict.setdefault("a", {}) on the first line.
Luckily, there are directives to not auto-format some lines:
[black] doesn’t reformat lines that end with # fmt: skip
Yet this doesn't work:
v = (
foo_dict # fmt: skip
.setdefault("a", {})
.setdefault("b", {})
.setdefault("c", {})
.setdefault("d", {})
.setdefault("e", {})
)
becomes:
v = (
foo_dict.setdefault("a", {}) # fmt: skip
.setdefault("b", {})
.setdefault("c", {})
.setdefault("d", {})
.setdefault("e", {})
)
Since the line foo_dict # fmt: skip ends with # fmt: skip, I would expect black to leave it alone.
Playground link
Say I'd like to format my code like so:
Black will of course reformat this to put
foo_dict.setdefault("a", {})on the first line.Luckily, there are directives to not auto-format some lines:
Yet this doesn't work:
becomes:
Since the line
foo_dict # fmt: skipends with# fmt: skip, I would expect black to leave it alone.Playground link