MCPcopy Create free account
hub / github.com/bpython/bpython / ParameterNameCompletion

Class ParameterNameCompletion

bpython/autocomplete.py:574–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572
573
574class ParameterNameCompletion(BaseCompletionType):
575 def matches(
576 self,
577 cursor_offset: int,
578 line: str,
579 *,
580 funcprops: inspection.FuncProps | None = None,
581 **kwargs: Any,
582 ) -> set[str] | None:
583 if funcprops is None:
584 return None
585
586 r = self.locate(cursor_offset, line)
587 if r is None:
588 return None
589
590 matches = {
591 f"{name}="
592 for name in funcprops.argspec.args
593 if isinstance(name, str) and name.startswith(r.word)
594 }
595 matches.update(
596 f"{name}="
597 for name in funcprops.argspec.kwonly
598 if name.startswith(r.word)
599 )
600 return matches if matches else None
601
602 def locate(self, cursor_offset: int, line: str) -> LinePart | None:
603 r = lineparts.current_word(cursor_offset, line)
604 if r and r.word[-1] == "(":
605 # if the word ends with a (, it's the parent word with an empty
606 # param. Return an empty word
607 return lineparts.LinePart(r.stop, r.stop, "")
608 return r
609
610
611class ExpressionAttributeCompletion(AttrCompletion):

Callers 1

get_default_completerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected