Skip to content

Commit a040252

Browse files
Add support for Python's new lazy import syntax (#4080)
* Add lazy keyword. * Add a test case.
1 parent e394eea commit a040252

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/languages/python.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default {
5858
},
5959
},
6060
'keyword':
61-
/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
61+
/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield|lazy)\b/,
6262
'builtin':
6363
/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
6464
'boolean': /\b(?:False|None|True)\b/,

tests/languages/python/keyword_feature.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pass print raise return
99
try while with yield
1010
nonlocal
1111
and not or
12-
match case _:
12+
match case _: lazy
1313

1414
----------------------------------------------------
1515

@@ -25,7 +25,7 @@ match case _:
2525
["keyword", "try"], ["keyword", "while"], ["keyword", "with"], ["keyword", "yield"],
2626
["keyword", "nonlocal"],
2727
["keyword", "and"], ["keyword", "not"], ["keyword", "or"],
28-
["keyword", "match"], ["keyword", "case"], ["keyword", "_"], ["punctuation", ":"]
28+
["keyword", "match"], ["keyword", "case"], ["keyword", "_"], ["punctuation", ":"], ["keyword", "lazy"]
2929
]
3030

3131
----------------------------------------------------

0 commit comments

Comments
 (0)