MCPcopy Create free account
hub / github.com/ipython/traitlets / _dedent

Function _dedent

traitlets/utils/text.py:15–31  ·  view source on GitHub ↗

Equivalent of textwrap.dedent that ignores unindented first line.

(text: str)

Source from the content-addressed store, hash-verified

13
14
15def _dedent(text: str) -> str:
16 """Equivalent of textwrap.dedent that ignores unindented first line."""
17
18 if text.startswith("\n"):
19 # text starts with blank line, don't ignore the first line
20 return textwrap.dedent(text)
21
22 # split first line
23 splits = text.split("\n", 1)
24 if len(splits) == 1:
25 # only one line
26 return textwrap.dedent(text)
27
28 first, rest = splits
29 # dedent everything but the first line
30 rest = textwrap.dedent(rest)
31 return "\n".join([first, rest])
32
33
34def wrap_paragraphs(text: str, ncols: int = 80) -> list[str]:

Callers 1

wrap_paragraphsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…