MCPcopy Create free account
hub / github.com/ipython/ipython / completions_sorting_key

Function completions_sorting_key

IPython/core/completer.py:293–322  ·  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

291
292
293def completions_sorting_key(word):
294 """key for sorting completions
295
296 This does several things:
297
298 - Demote any completions starting with underscores to the end
299 - Insert any %magic and %%cellmagic completions in the alphabetical order
300 by their name
301 """
302 prio1, prio2 = 0, 0
303
304 if word.startswith('__'):
305 prio1 = 2
306 elif word.startswith('_'):
307 prio1 = 1
308
309 if word.endswith('='):
310 prio1 = -1
311
312 if word.startswith('%%'):
313 # If there's another % in there, this is something else, so leave it alone
314 if not "%" in word[2:]:
315 word = word[2:]
316 prio2 = 2
317 elif word.startswith('%'):
318 if not "%" in word[1:]:
319 word = word[1:]
320 prio2 = 1
321
322 return prio1, word, prio2
323
324
325class _FakeJediCompletion:

Callers 1

_completeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected