MCPcopy Index your code
hub / github.com/python/mypy / split_directive

Function split_directive

mypy/config_parser.py:608–634  ·  view source on GitHub ↗

Split s on commas, except during quoted sections. Returns the parts and a list of error messages.

(s: str)

Source from the content-addressed store, hash-verified

606
607
608def split_directive(s: str) -> tuple[list[str], list[str]]:
609 """Split s on commas, except during quoted sections.
610
611 Returns the parts and a list of error messages."""
612 parts = []
613 cur: list[str] = []
614 errors = []
615 i = 0
616 while i < len(s):
617 if s[i] == ",":
618 parts.append("".join(cur).strip())
619 cur = []
620 elif s[i] == '"':
621 i += 1
622 while i < len(s) and s[i] != '"':
623 cur.append(s[i])
624 i += 1
625 if i == len(s):
626 errors.append("Unterminated quote in configuration comment")
627 cur.clear()
628 else:
629 cur.append(s[i])
630 i += 1
631 if cur:
632 parts.append("".join(cur).strip())
633
634 return parts, errors
635
636
637def mypy_comments_to_config_map(line: str, template: Options) -> tuple[dict[str, str], list[str]]:

Callers 1

Calls 5

lenFunction · 0.85
appendMethod · 0.80
stripMethod · 0.80
joinMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…