aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/idlelib/autocomplete.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2021-10-16 18:44:00 -0400
committerGitHub <noreply@github.com>2021-10-16 18:44:00 -0400
commit42ac06dcd234bdda989dcfe854ac5173337024c9 (patch)
treec85c0b31fa39b9153f9144d0bb3bcaeba31ce568 /Lib/idlelib/autocomplete.py
parentb9cdd0fb9c463c2503a4d854bb6529a9db58fe1b (diff)
downloadcpython-42ac06dcd234bdda989dcfe854ac5173337024c9.tar.gz
cpython-42ac06dcd234bdda989dcfe854ac5173337024c9.zip
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.
Diffstat (limited to 'Lib/idlelib/autocomplete.py')
-rw-r--r--Lib/idlelib/autocomplete.py10
1 files changed, 7 insertions, 3 deletions
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))