Completion object used and returned by IPython completers. .. warning:: Unstable This function is unstable, API may change without warning. It will also raise unless use in proper context manager. This act as a middle ground :any:`Completion` object between t
| 476 | |
| 477 | |
| 478 | class Completion: |
| 479 | """ |
| 480 | Completion object used and returned by IPython completers. |
| 481 | |
| 482 | .. warning:: |
| 483 | |
| 484 | Unstable |
| 485 | |
| 486 | This function is unstable, API may change without warning. |
| 487 | It will also raise unless use in proper context manager. |
| 488 | |
| 489 | This act as a middle ground :any:`Completion` object between the |
| 490 | :class:`jedi.api.classes.Completion` object and the Prompt Toolkit completion |
| 491 | object. While Jedi need a lot of information about evaluator and how the |
| 492 | code should be ran/inspected, PromptToolkit (and other frontend) mostly |
| 493 | need user facing information. |
| 494 | |
| 495 | - Which range should be replaced replaced by what. |
| 496 | - Some metadata (like completion type), or meta information to displayed to |
| 497 | the use user. |
| 498 | |
| 499 | For debugging purpose we can also store the origin of the completion (``jedi``, |
| 500 | ``IPython.python_matches``, ``IPython.magics_matches``...). |
| 501 | """ |
| 502 | |
| 503 | __slots__ = ['start', 'end', 'text', 'type', 'signature', '_origin'] |
| 504 | |
| 505 | def __init__( |
| 506 | self, |
| 507 | start: int, |
| 508 | end: int, |
| 509 | text: str, |
| 510 | *, |
| 511 | type: Optional[str] = None, |
| 512 | _origin="", |
| 513 | signature="", |
| 514 | ) -> None: |
| 515 | warnings.warn( |
| 516 | "``Completion`` is a provisional API (as of IPython 6.0). " |
| 517 | "It may change without warnings. " |
| 518 | "Use in corresponding context manager.", |
| 519 | category=ProvisionalCompleterWarning, |
| 520 | stacklevel=2, |
| 521 | ) |
| 522 | |
| 523 | self.start = start |
| 524 | self.end = end |
| 525 | self.text = text |
| 526 | self.type = type |
| 527 | self.signature = signature |
| 528 | self._origin = _origin |
| 529 | |
| 530 | def __repr__(self): |
| 531 | return '<Completion start=%s end=%s text=%r type=%r, signature=%r,>' % \ |
| 532 | (self.start, self.end, self.text, self.type or '?', self.signature or '?') |
| 533 | |
| 534 | def __eq__(self, other) -> bool: |
| 535 | """ |
no outgoing calls
searching dependent graphs…