]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-139003: Use frozenset for module level attributes in _pyrepl.utils (#139004)
authorPieter Eendebak <pieter.eendebak@gmail.com>
Sat, 28 Mar 2026 20:21:19 +0000 (21:21 +0100)
committerGitHub <noreply@github.com>
Sat, 28 Mar 2026 20:21:19 +0000 (20:21 +0000)
Use frozenset for module level attributes

Lib/_pyrepl/utils.py

index 25d7ac1bd0b14e5c0954b54cb7764e8c0feb0566..7175d57a9e319e3061745afe0481b140b1f8538e 100644 (file)
@@ -19,9 +19,9 @@ from .trace import trace
 ANSI_ESCAPE_SEQUENCE = re.compile(r"\x1b\[[ -@]*[A-~]")
 ZERO_WIDTH_BRACKET = re.compile(r"\x01.*?\x02")
 ZERO_WIDTH_TRANS = str.maketrans({"\x01": "", "\x02": ""})
-IDENTIFIERS_AFTER = {"def", "class"}
-KEYWORD_CONSTANTS = {"True", "False", "None"}
-BUILTINS = {str(name) for name in dir(builtins) if not name.startswith('_')}
+IDENTIFIERS_AFTER = frozenset({"def", "class"})
+KEYWORD_CONSTANTS = frozenset({"True", "False", "None"})
+BUILTINS = frozenset({str(name) for name in dir(builtins) if not name.startswith('_')})
 
 
 def THEME(**kwargs):
@@ -226,8 +226,8 @@ def gen_colors_from_token_stream(
                     yield ColorSpan(span, "builtin")
 
 
-keyword_first_sets_match = {"False", "None", "True", "await", "lambda", "not"}
-keyword_first_sets_case = {"False", "None", "True"}
+keyword_first_sets_match = frozenset({"False", "None", "True", "await", "lambda", "not"})
+keyword_first_sets_case = frozenset({"False", "None", "True"})
 
 
 def is_soft_keyword_used(*tokens: TI | None) -> bool: