MCPcopy Index your code
hub / github.com/ipython/ipython / dedent

Function dedent

IPython/utils/text.py:352–376  ·  view source on GitHub ↗

Equivalent of textwrap.dedent that ignores unindented first line. This means it will still dedent strings like: '''foo is a bar ''' For use in wrap_paragraphs.

(text: str)

Source from the content-addressed store, hash-verified

350
351
352def dedent(text: str) -> str:
353 """Equivalent of textwrap.dedent that ignores unindented first line.
354
355 This means it will still dedent strings like:
356 '''foo
357 is a bar
358 '''
359
360 For use in wrap_paragraphs.
361 """
362
363 if text.startswith('\n'):
364 # text starts with blank line, don't ignore the first line
365 return textwrap.dedent(text)
366
367 # split first line
368 splits = text.split('\n',1)
369 if len(splits) == 1:
370 # only one line
371 return textwrap.dedent(text)
372
373 first, rest = splits
374 # dedent everything but the first line
375 rest = textwrap.dedent(rest)
376 return '\n'.join([first, rest])
377
378
379def strip_email_quotes(text: str) -> str:

Callers 15

_fill_textMethod · 0.90
_magic_docsMethod · 0.90
test_skip_dt_decoratorFunction · 0.90
format_docstringFunction · 0.90
_function_magic_markerFunction · 0.85
leading_indentFunction · 0.85
__call__Method · 0.85
getsourceFunction · 0.85
test_xmode_skipFunction · 0.85
_decorator_skip_setupFunction · 0.85

Calls

no outgoing calls

Tested by 15

test_skip_dt_decoratorFunction · 0.72
test_xmode_skipFunction · 0.68
_decorator_skip_setupFunction · 0.68
test_where_erase_valueFunction · 0.68
create_test_modulesFunction · 0.68
test_mix_termsMethod · 0.68
test_multiline_timeFunction · 0.68
test_save_with_no_argsFunction · 0.68
test_nested_genexprMethod · 0.68
iprcFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…