From 42ac06dcd234bdda989dcfe854ac5173337024c9 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sat, 16 Oct 2021 18:44:00 -0400 Subject: bpo-45495: Add 'case' and 'match' to IDLE completions list. (GH-29000) Since the keyword list is frozen, only compute it once per session. The colorizer already handles context keywords. --- Lib/idlelib/autocomplete.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Lib/idlelib/autocomplete.py') diff --git a/Lib/idlelib/autocomplete.py b/Lib/idlelib/autocomplete.py index bb7ee035c4f..032d3122531 100644 --- a/Lib/idlelib/autocomplete.py +++ b/Lib/idlelib/autocomplete.py @@ -9,6 +9,12 @@ import os import string import sys +# Modified keyword list is used in fetch_completions. +completion_kwds = [s for s in keyword.kwlist + if s not in {'True', 'False', 'None'}] # In builtins. +completion_kwds.extend(('match', 'case')) # Context keywords. +completion_kwds.sort() + # Two types of completions; defined here for autocomplete_w import below. ATTRS, FILES = 0, 1 from idlelib import autocomplete_w @@ -177,9 +183,7 @@ class AutoComplete: namespace = {**__main__.__builtins__.__dict__, **__main__.__dict__} bigl = eval("dir()", namespace) - kwds = (s for s in keyword.kwlist - if s not in {'True', 'False', 'None'}) - bigl.extend(kwds) + bigl.extend(completion_kwds) bigl.sort() if "__all__" in bigl: smalll = sorted(eval("__all__", namespace)) -- cgit v1.2.3