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

Class MagicMethodCompletion

bpython/autocomplete.py:506–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504
505
506class MagicMethodCompletion(BaseCompletionType):
507 def matches(
508 self,
509 cursor_offset: int,
510 line: str,
511 *,
512 current_block: str | None = None,
513 complete_magic_methods: bool | None = None,
514 **kwargs: Any,
515 ) -> set[str] | None:
516 if (
517 current_block is None
518 or complete_magic_methods is None
519 or not complete_magic_methods
520 ):
521 return None
522
523 r = self.locate(cursor_offset, line)
524 if r is None:
525 return None
526 if "class" not in current_block:
527 return None
528 return {name for name in MAGIC_METHODS if name.startswith(r.word)}
529
530 def locate(self, cursor_offset: int, line: str) -> LinePart | None:
531 return lineparts.current_method_definition_name(cursor_offset, line)
532
533
534class GlobalCompletion(BaseCompletionType):

Callers 1

get_default_completerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected