File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed
crates/languages/src/python Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change
1
+ ; Identifier naming conventions; these "soft conventions" should stay at the top of the file as they're often overridden
2
+
3
+ ; CamelCase for classes
4
+ ((identifier) @type.class
5
+ (#match? @type.class "^_*[A-Z][A-Za-z0-9_]*$"))
6
+
7
+ ; ALL_CAPS for constants:
8
+ ((identifier) @constant
9
+ (#match? @constant "^_*[A-Z][A-Z0-9_]*$"))
10
+
1
11
(attribute attribute: (identifier) @property )
2
12
(type (identifier) @type )
3
13
(generic_type (identifier) @type )
4
14
5
15
; Type alias
6
16
(type_alias_statement "type" @keyword )
7
17
8
- ; Identifier naming conventions
9
-
10
- ((identifier) @type.class
11
- (#match? @type.class "^[A-Z]"))
12
-
13
- ((identifier) @constant
14
- (#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
15
-
16
18
; TypeVar with constraints in type parameters
17
19
(type
18
20
(tuple (identifier) @type )
47
49
48
50
(call
49
51
function: (identifier) @type.class.call
50
- (#match? @type.class.call "^[A-Z][A-Z0- 9_]*[a-z] "))
52
+ (#match? @type.class.call "^_* [A-Z][A-Za-z0- 9_]*$ "))
51
53
52
- ; Builtin functions
54
+ ; Builtins
53
55
54
56
((call
55
57
function: (identifier) @function.builtin )
56
58
(#match?
57
59
@function.builtin
58
60
"^(abs|all|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|vars|zip|__import__)$"))
59
61
62
+ ((identifier) @type.builtin
63
+ (#match? @type.builtin "^(int|float|complex|bool|list|tuple|range|str|bytes|bytearray|memoryview|set|frozenset|dict)$"))
64
+
60
65
; Literals
61
66
62
67
[
185
190
"elif"
186
191
"else"
187
192
"except"
193
+ "except*"
188
194
"exec"
189
195
"finally"
190
196
"for"
You can’t perform that action at this time.
0 commit comments