:feature 'constant
:language 'python
'([(true) (false) (none)] @font-lock-constant-face
- ((identifier) @font-lock-constant-face
+ ((assignment (identifier) @font-lock-constant-face)
+ (:match "\\`[A-Z][A-Z0-9_]+\\'" @font-lock-constant-face))
+ ((call arguments: (argument_list (identifier) @font-lock-constant-face))
(:match "\\`[A-Z][A-Z0-9_]+\\'" @font-lock-constant-face))
((attribute
attribute: (identifier) @font-lock-constant-face)
(ert-deftest python-ts-mode-nested-types-face-1 ()
(python-ts-tests-with-temp-buffer
"def func(v:dict[ list[ tuple[str] ], int | None] | None):"
- (dolist (test '("dict" "list" "tuple" "str" "int" "None" "None"))
+ (dolist (test '("dict" "list" "tuple" "str" "int"))
(search-forward test)
(goto-char (match-beginning 0))
- (should (eq (face-at-point) 'font-lock-type-face)))))
+ (should (eq (face-at-point) 'font-lock-type-face)))
+
+ (goto-char (point-min))
+ (dolist (test '("None" "None"))
+ (search-forward test)
+ (goto-char (match-beginning 0))
+ (should (eq (face-at-point) 'font-lock-constant-face)))))
(ert-deftest python-ts-mode-union-types-face-1 ()
(python-ts-tests-with-temp-buffer
"def f(val: tuple[tuple, list[Lvl1 | Lvl2[Lvl3[Lvl4[Lvl5 | None]], Lvl2]]]):"
- (dolist (test '("tuple" "tuple" "list" "Lvl1" "Lvl2" "Lvl3" "Lvl4" "Lvl5" "None" "Lvl2"))
+ (dolist (test '("tuple" "tuple" "list" "Lvl1" "Lvl2" "Lvl3" "Lvl4" "Lvl5" "Lvl2"))
(search-forward test)
(goto-char (match-beginning 0))
- (should (eq (face-at-point) 'font-lock-type-face)))))
+ (should (eq (face-at-point) 'font-lock-type-face)))
+
+ (goto-char (point-min))
+ (dolist (test '("None"))
+ (search-forward test)
+ (goto-char (match-beginning 0))
+ (should (eq (face-at-point) 'font-lock-constant-face)))))
(ert-deftest python-ts-mode-union-types-face-2 ()
(python-ts-tests-with-temp-buffer
"def f(val: Type0 | Type1[Type2, pack0.Type3] | pack1.pack2.Type4 | None):"
- (dolist (test '("Type0" "Type1" "Type2" "Type3" "Type4" "None"))
+ (dolist (test '("Type0" "Type1" "Type2" "Type3" "Type4"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) 'font-lock-type-face)))
+ (goto-char (point-min))
+ (dolist (test '("None"))
+ (search-forward test)
+ (goto-char (match-beginning 0))
+ (should (eq (face-at-point) 'font-lock-constant-face)))
+
(goto-char (point-min))
(dolist (test '("pack0" "pack1" "pack2"))
(search-forward test)