Skip to content

Commit 7d8319f

Browse files
committed
added python keywords to autocomplete list
1 parent bac66a5 commit 7d8319f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

custom_components/pyscript/eval.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import builtins
66
import importlib
77
import inspect
8+
import keyword
89
import logging
910
import sys
1011

@@ -220,8 +221,8 @@ async def eval_decorators(self, ast_ctx):
220221
kwargs = {}
221222
for arg in dec.args:
222223
args.append(await ast_ctx.aeval(arg))
223-
for keyword in dec.keywords:
224-
kwargs[keyword.arg] = await ast_ctx.aeval(keyword.value)
224+
for keyw in dec.keyw:
225+
kwargs[keyw.arg] = await ast_ctx.aeval(keyw.value)
225226
if len(kwargs) == 0:
226227
kwargs = None
227228
self.decorators.append([dec.func.id, args, kwargs])
@@ -1325,6 +1326,9 @@ def completions(self, root):
13251326
words.add(f"{name}.{attr}")
13261327
except Exception: # pylint: disable=broad-except
13271328
pass
1329+
for keyw in set(keyword.kwlist) - {"yield", "lambda", "with", "assert"}:
1330+
if keyw.lower().startswith(root):
1331+
words.add(keyw)
13281332
sym_table = BUILTIN_AST_FUNCS_FACTORY.copy()
13291333
for name, value in builtins.__dict__.items():
13301334
if name[0] != "_" and name not in BUILTIN_EXCLUDE:

0 commit comments

Comments
 (0)