MCPcopy Index your code
hub / github.com/ipython/ipython / completions_sorting_key

Function completions_sorting_key

IPython/core/completer.py:420–449  ·  view source on GitHub ↗

key for sorting completions This does several things: - Demote any completions starting with underscores to the end - Insert any %magic and %%cellmagic completions in the alphabetical order by their name

(word)

Source from the content-addressed store, hash-verified

418
419
420def completions_sorting_key(word):
421 """key for sorting completions
422
423 This does several things:
424
425 - Demote any completions starting with underscores to the end
426 - Insert any %magic and %%cellmagic completions in the alphabetical order
427 by their name
428 """
429 prio1, prio2 = 0, 0
430
431 if word.startswith('__'):
432 prio1 = 2
433 elif word.startswith('_'):
434 prio1 = 1
435
436 if word.endswith('='):
437 prio1 = -1
438
439 if word.startswith('%%'):
440 # If there's another % in there, this is something else, so leave it alone
441 if "%" not in word[2:]:
442 word = word[2:]
443 prio2 = 2
444 elif word.startswith('%'):
445 if "%" not in word[1:]:
446 word = word[1:]
447 prio2 = 1
448
449 return prio1, word, prio2
450
451
452class _FakeJediCompletion:

Callers 1

_sortMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…