Reformats 'text': * removes leading and trailing blank lines * ensures that it does not end with a newline * dedents so the first nonwhite character on any line is at column "indent"
(text: str, *, indent: int = 0)
| 150 | |
| 151 | @functools.lru_cache() |
| 152 | def normalize_snippet(text: str, *, indent: int = 0) -> str: |
| 153 | """ |
| 154 | Reformats 'text': |
| 155 | * removes leading and trailing blank lines |
| 156 | * ensures that it does not end with a newline |
| 157 | * dedents so the first nonwhite character on any line is at column "indent" |
| 158 | """ |
| 159 | text = _strip_leading_and_trailing_blank_lines(text) |
| 160 | text = textwrap.dedent(text) |
| 161 | if indent: |
| 162 | text = textwrap.indent(text, " " * indent) |
| 163 | return text |
| 164 | |
| 165 | |
| 166 | def format_escape(text: str) -> str: |
nothing calls this directly
no test coverage detected
searching dependent graphs…