Skip to content

Commit 60a6e16

Browse files
committed
Fix for richer type annotations
1 parent 50aa96b commit 60a6e16

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

grammars/python.cson

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
{
3838
'include': '#language_variables'
3939
}
40+
{
41+
'match': '^\\s*\\w+\\s*:\\s*([\\w\\.]+(?:\\[[\\w\\.,\\s]+\\])?)' # TODO Currently matches inside dict too :(
42+
'captures':
43+
'1':
44+
'name': 'storage.type.python'
45+
}
4046
{
4147
'match': '\\b(?i:(0x\\h*)L)'
4248
'name': 'constant.numeric.integer.long.hexadecimal.python'
@@ -289,7 +295,7 @@
289295
{
290296
# param = 3
291297
# param: int = 3
292-
'begin': '(?:(\\*{0,2})|\\b)([a-zA-Z_][\\w_]*)\\s*(?:(:)\\s*([a-zA-Z_][\\w_]*))?\\s*(=)\\s*'
298+
'begin': '(?:(\\*{0,2})|\\b)([a-zA-Z_][\\w_]*)\\s*(?:(:)\\s*([\\w\\.]+(?:\\[[\\w\\.,\\s]+\\])?))?\\s*(=)\\s*'
293299
'beginCaptures':
294300
'1':
295301
'name': 'keyword.operator.unpacking.arguments.python'
@@ -311,7 +317,7 @@
311317
{
312318
# param
313319
# param: int
314-
'match': '(?:(\\*{0,2})|\\b)([a-zA-Z_][\\w_]*)\\s*(?:(:)\\s*([a-zA-Z_][\\w_]*))?'
320+
'match': '(?:(\\*{0,2})|\\b)([a-zA-Z_][\\w_]*)\\s*(?:(:)\\s*([\\w\\.]+(?:\\[[\\w\\.,\\s]+\\])?))?'
315321
'captures':
316322
'1':
317323
'name': 'keyword.operator.unpacking.arguments.python'
@@ -329,7 +335,7 @@
329335
]
330336
}
331337
{
332-
'match': '(->)\\s*([A-Za-z_][\\w_]*)(?=\\s*:)'
338+
'match': '(->)\\s*([\\w\\.]+(?:\\[[\\w\\.,\\s]+\\])?)(?=\\s*:)'
333339
'captures':
334340
'1':
335341
'name': 'keyword.operator.function-annotation.python'

0 commit comments

Comments
 (0)