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+
111(attribute attribute: (identifier) @property )
212(type (identifier) @type )
313(generic_type (identifier) @type )
414
515; Type alias
616(type_alias_statement "type" @keyword )
717
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-
1618; TypeVar with constraints in type parameters
1719(type
1820 (tuple (identifier) @type )
4749
4850(call
4951 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_]*$ "))
5153
52- ; Builtin functions
54+ ; Builtins
5355
5456((call
5557 function: (identifier) @function.builtin )
5658 (#match?
5759 @function.builtin
5860 "^(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__)$"))
5961
62+ ((identifier) @type.builtin
63+ (#match? @type.builtin "^(int|float|complex|bool|list|tuple|range|str|bytes|bytearray|memoryview|set|frozenset|dict)$"))
64+
6065; Literals
6166
6267[
185190 "elif"
186191 "else"
187192 "except"
193+ "except*"
188194 "exec"
189195 "finally"
190196 "for"
You can’t perform that action at this time.
0 commit comments