Returns an iterator over the possible completions .. warning:: Unstable This function is unstable, API may change without warning. It will also raise unless use in proper context manager. Parameters ---------- text : st
(self, text: str, offset: int)
| 3270 | return None |
| 3271 | |
| 3272 | def completions(self, text: str, offset: int)->Iterator[Completion]: |
| 3273 | """ |
| 3274 | Returns an iterator over the possible completions |
| 3275 | |
| 3276 | .. warning:: |
| 3277 | |
| 3278 | Unstable |
| 3279 | |
| 3280 | This function is unstable, API may change without warning. |
| 3281 | It will also raise unless use in proper context manager. |
| 3282 | |
| 3283 | Parameters |
| 3284 | ---------- |
| 3285 | text : str |
| 3286 | Full text of the current input, multi line string. |
| 3287 | offset : int |
| 3288 | Integer representing the position of the cursor in ``text``. Offset |
| 3289 | is 0-based indexed. |
| 3290 | |
| 3291 | Yields |
| 3292 | ------ |
| 3293 | Completion |
| 3294 | |
| 3295 | Notes |
| 3296 | ----- |
| 3297 | The cursor on a text can either be seen as being "in between" |
| 3298 | characters or "On" a character depending on the interface visible to |
| 3299 | the user. For consistency the cursor being on "in between" characters X |
| 3300 | and Y is equivalent to the cursor being "on" character Y, that is to say |
| 3301 | the character the cursor is on is considered as being after the cursor. |
| 3302 | |
| 3303 | Combining characters may span more that one position in the |
| 3304 | text. |
| 3305 | |
| 3306 | .. note:: |
| 3307 | |
| 3308 | If ``IPCompleter.debug`` is :py:data:`True` will yield a ``--jedi/ipython--`` |
| 3309 | fake Completion token to distinguish completion returned by Jedi |
| 3310 | and usual IPython completion. |
| 3311 | |
| 3312 | .. note:: |
| 3313 | |
| 3314 | Completions are not completely deduplicated yet. If identical |
| 3315 | completions are coming from different sources this function does not |
| 3316 | ensure that each completion object will only be present once. |
| 3317 | """ |
| 3318 | warnings.warn("_complete is a provisional API (as of IPython 6.0). " |
| 3319 | "It may change without warnings. " |
| 3320 | "Use in corresponding context manager.", |
| 3321 | category=ProvisionalCompleterWarning, stacklevel=2) |
| 3322 | |
| 3323 | seen = set() |
| 3324 | profiler:Optional[cProfile.Profile] |
| 3325 | try: |
| 3326 | if self.profile_completions: |
| 3327 | import cProfile |
| 3328 | profiler = cProfile.Profile() |
| 3329 | profiler.enable() |