MCPcopy
hub / github.com/huggingface/transformers / get_indent

Function get_indent

utils/check_copies.py:547–563  ·  view source on GitHub ↗

Find the indent in the first non empty line in a code sample. Args: code (`str`): The code to inspect. Returns: `str`: The indent looked at (as string).

(code: str)

Source from the content-addressed store, hash-verified

545
546
547def get_indent(code: str) -> str:
548 """
549 Find the indent in the first non empty line in a code sample.
550
551 Args:
552 code (`str`): The code to inspect.
553
554 Returns:
555 `str`: The indent looked at (as string).
556 """
557 lines = code.split("\n")
558 idx = 0
559 while idx < len(lines) and len(lines[idx]) == 0:
560 idx += 1
561 if idx < len(lines):
562 return re.search(r"^(\s*)\S", lines[idx]).groups()[0]
563 return ""
564
565
566def run_ruff(code, check=False):

Callers 3

find_code_and_splitsFunction · 0.70
stylifyFunction · 0.70
is_copy_consistentFunction · 0.70

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected