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

Function parse_all_signatures

mypy/stubdoc.py:496–516  ·  view source on GitHub ↗

Parse all signatures in a given reST document. Return lists of found signatures for functions and classes.

(lines: Sequence[str])

Source from the content-addressed store, hash-verified

494
495
496def parse_all_signatures(lines: Sequence[str]) -> tuple[list[Sig], list[Sig]]:
497 """Parse all signatures in a given reST document.
498
499 Return lists of found signatures for functions and classes.
500 """
501 sigs = []
502 class_sigs = []
503 for line in lines:
504 line = line.strip()
505 m = re.match(r"\.\. *(function|method|class) *:: *[a-zA-Z_]", line)
506 if m:
507 sig = line.split("::")[1].strip()
508 parsed = parse_signature(sig)
509 if parsed:
510 name, fixed, optional = parsed
511 if m.group(1) != "class":
512 sigs.append((name, build_signature(fixed, optional)))
513 else:
514 class_sigs.append((name, build_signature(fixed, optional)))
515
516 return sorted(sigs), sorted(class_sigs)
517
518
519def find_unique_signatures(sigs: Sequence[Sig]) -> list[Sig]:

Callers 2

from_doc_dirMethod · 0.90

Calls 7

parse_signatureFunction · 0.85
build_signatureFunction · 0.85
sortedFunction · 0.85
stripMethod · 0.80
splitMethod · 0.80
groupMethod · 0.80
appendMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…