Variable: python-font-lock-keywords-maximum-decoration

python-font-lock-keywords-maximum-decoration is a variable defined in python.el.gz.

Value

Large value
((python--font-lock-f-strings)
 ("\\_<def[[:space:]]+\\([_[:alpha:]][_[:word:]]*\\)"
  (1 font-lock-function-name-face))
 ("\\_<class[[:space:]]+\\([_[:alpha:]][_[:word:]]*\\)"
  (1 font-lock-type-face))
 "\\_<\\(?:and\\|del\\|from\\|not\\|while\\|as\\|elif\\|global\\|or\\|with\\|assert\\|else\\|if\\|pass\\|yield\\|break\\|except\\|import\\|class\\|in\\|raise\\|continue\\|finally\\|is\\|return\\|def\\|for\\|lambda\\|try\\|nonlocal\\|async[[:space:]]+\\(?:def\\|for\\|with\\)\\|await\\|match\\|case\\|self\\)\\_>"
 ("\\(?:\\_<\\(?:__\\(?:\\(?:a\\(?:ll\\|nnotations\\)\\|bases\\|c\\(?:\\(?:losur\\|od\\)e\\)\\|d\\(?:efaults\\|ict\\|oc\\)\\|firstlineno\\|globals\\|import\\|kwdefaults\\|m\\(?:odule\\|ro\\)\\|name\\|package\\|qualname\\|\\(?:static_attribute\\|type_param\\)s\\)__\\)\\|a\\(?:bs\\|iter\\|ll\\|n\\(?:ext\\|y\\)\\|scii\\)\\|b\\(?:in\\|ool\\|reakpoint\\|yte\\(?:array\\|s\\)\\)\\|c\\(?:allable\\|hr\\|lassmethod\\|omp\\(?:ile\\|lex\\)\\)\\|d\\(?:elattr\\|i\\(?:ct\\|r\\|vmod\\)\\)\\|e\\(?:numerate\\|val\\|xec\\)\\|f\\(?:ilter\\|\\(?:loa\\|orma\\|rozense\\)t\\)\\|g\\(?:etattr\\|lobals\\)\\|h\\(?:as\\(?:attr\\|h\\)\\|e\\(?:lp\\|x\\)\\)\\|i\\(?:d\\|n\\(?:\\(?:pu\\)?t\\)\\|s\\(?:instance\\|subclass\\)\\|ter\\)\\|l\\(?:en\\|ist\\|ocals\\)\\|m\\(?:a[px]\\|emoryview\\|in\\)\\|next\\|o\\(?:bject\\|ct\\|pen\\|rd\\)\\|p\\(?:ow\\|r\\(?:int\\|operty\\)\\)\\|r\\(?:ange\\|e\\(?:pr\\|versed\\)\\|ound\\)\\|s\\(?:et\\(?:attr\\)?\\|lice\\|orted\\|t\\(?:aticmethod\\|r\\)\\|u\\(?:m\\|per\\)\\)\\|t\\(?:\\(?:upl\\|yp\\)e\\)\\|vars\\|zip\\)\\_>\\)"
  . font-lock-builtin-face)
 ("\\_<\\(?:Ellipsis\\|False\\|No\\(?:ne\\|tImplemented\\)\\|True\\|__debug__\\|c\\(?:opyright\\|redits\\)\\|exit\\|license\\|quit\\)\\_>"
  . font-lock-constant-face)
 ("^[	 ]*\\(@[_[:word:]]+\\(?:\\.[_[:word:]]+\\)*\\)"
  (1 font-lock-type-face))
 ("\\(?:\\_<\\(?:A\\(?:\\(?:rithmetic\\|ssertion\\|ttribute\\)Error\\)\\|B\\(?:aseException\\(?:Group\\)?\\|lockingIOError\\|rokenPipeError\\|ufferError\\|ytesWarning\\)\\|C\\(?:\\(?:hildProcess\\|onnection\\(?:Aborted\\|Re\\(?:fused\\|set\\)\\)?\\)Error\\)\\|DeprecationWarning\\|E\\(?:OFError\\|n\\(?:codingWarning\\|vironmentError\\)\\|xception\\(?:Group\\)?\\)\\|F\\(?:ile\\(?:\\(?:Exists\\|NotFound\\)Error\\)\\|loatingPointError\\|utureWarning\\)\\|GeneratorExit\\|I\\(?:OError\\|mport\\(?:Error\\|Warning\\)\\|\\(?:n\\(?:de\\(?:ntation\\|x\\)\\|terrupted\\)\\|sADirectory\\)Error\\)\\|Key\\(?:Error\\|boardInterrupt\\)\\|LookupError\\|M\\(?:\\(?:emory\\|oduleNotFound\\)Error\\)\\|N\\(?:\\(?:ame\\|ot\\(?:ADirectory\\|Implemented\\)\\)Error\\)\\|O\\(?:\\(?:S\\|verflow\\)Error\\)\\|P\\(?:e\\(?:ndingDeprecationWarning\\|rmissionError\\)\\|\\(?:rocessLookup\\|ythonFinalization\\)Error\\)\\|R\\(?:e\\(?:cursionError\\|ferenceError\\|sourceWarning\\)\\|untime\\(?:Error\\|Warning\\)\\)\\|S\\(?:top\\(?:\\(?:Async\\)?Iteration\\)\\|y\\(?:ntax\\(?:Error\\|Warning\\)\\|stemE\\(?:rror\\|xit\\)\\)\\)\\|T\\(?:\\(?:ab\\|imeout\\|ype\\)Error\\)\\|U\\(?:n\\(?:boundLocalError\\|icode\\(?:DecodeError\\|E\\(?:\\(?:ncodeE\\)?rror\\)\\|TranslateError\\|Warning\\)\\)\\|serWarning\\)\\|V\\(?:\\(?:MS\\|alue\\)Error\\)\\|W\\(?:arning\\|indowsError\\)\\|ZeroDivisionError\\)\\_>\\)"
  . font-lock-type-face)
 (#[257
    "\301\211\302\300\303#\203$�\304 A@\204�\301f\305=\204�\306u\266\303\301\211\262\204�\207"
    ["\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*\\(?::[[:space:]]*\\([^\n%&*+/<->^|~-]+\\)[[:space:]]*\\)?\\(\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)\\)"
     nil re-search-forward t syntax-ppss 61 -1]
    7
    ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/progmodes/python.elc"
     . 13774)]
  (1 font-lock-variable-name-face) (3 'font-lock-operator-face)
  ("[_[:alpha:]][_[:word:]]*"
   (progn
     (when-let* ((type-start (match-beginning 2)))
       (goto-char type-start))
     (match-end 0))
   nil (0 font-lock-type-face)))
 (#[257
    "\301\211\302\300\303#\203$�\304 A@\204�\301f\305=\204�\306u\266\303\301\211\262\204�\207"
    ["\\(?:[([][[:space:]]*\\)?\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*,[[:space:]]*\\(?:\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*[_[:alpha:]][_[:word:]]*\\(?:\\[[^]]+]\\)?[[:space:]]*,[[:space:]]*\\)*\\(?:\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*[_[:alpha:]][_[:word:]]*\\(?:\\[[^]]+]\\)?[[:space:]]*\\)?\\(?:,[[:space:]]*\\)?\\(?:[])][[:space:]]*\\)?\\(\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)\\)"
     nil re-search-forward t syntax-ppss 61 -1]
    7
    ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/progmodes/python.elc"
     . 13774)]
  (1 font-lock-variable-name-face) (2 'font-lock-operator-face)
  ("\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?"
   (progn (goto-char (match-end 1)) (match-beginning 2)) nil
   (1 font-lock-variable-name-face)))
 (#[257
    "\301\211\302\300\303#\203$�\304 A@\204�\301f\305=\204�\306u\266\303\301\211\262\204�\207"
    ["\\(?:^\\|[;=]\\)[[:space:]]*[([][[:space:]]*\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*[])][[:space:]]*\\(\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)\\)"
     nil re-search-forward t syntax-ppss 61 -1]
    7
    ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/progmodes/python.elc"
     . 13774)]
  (1 font-lock-variable-name-face) (2 'font-lock-operator-face))
 ("\\(?:!=\\|\\*\\*\\|//\\|<[<=]\\|==\\|>[=>]\\|[%&*+/<=>|~^-]\\)"
  quote font-lock-operator-face)
 (#[257
    "\302\211\211\303\301\304#\262\2055�\305\306 8\211\205!�\307\310Ze]Td^\"\211\2053�\311u\210\300\302\312\304$\266\203\266\202\262\203D�\204D�\210\302\202�\205I�\207"
    ["\\(?:\\`\\|[^[:alnum:]]\\)[Bb]\\(?:\"\"\"\\|'''\\|[\"']\\)\\'"
     "[^\\]\\(\\\\\\\\\\|\\\\'\\|\\\\a\\|\\\\b\\|\\\\f\\|\\\\n\\|\\\\r\\|\\\\t\\|\\\\v\\|\\\\[0-7]\\{1,3\\}\\|\\\\x[[:xdigit:]][[:xdigit:]]\\)"
     nil re-search-forward t 8 syntax-ppss
     buffer-substring-no-properties 4 -1 string-match]
    14
    ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/progmodes/python.elc"
     . 13774)]
  (1 font-lock-constant-face t))
 (#[257
    "\302\211\211\303\301\304#\262\2055�\305\306 8\211\205!�\307\310Ze]Td^\"\211\2053�\311u\210\300\302\312\304$\266\203\266\202\262\203D�\204D�\210\302\202�\205I�\207"
    ["\\`\\(?:\\(?:[^[:alnum:]]?[FUfu]\\)?\\(?:\"\"\"\\|'''\\)\\|[^z-a]?[^[:alnum:]]\\(?:\"\"\"\\|'''\\)\\|\\(?:[^z-a]\\{0,2\\}[^[:alnum:]]\\)?[FUfu][\"']\\|\\(?:[^z-a]\\{0,3\\}[^\"'[:alnum:]]\\)?[\"']\\)\\'"
     "[^\\]\\(\\\\\\\\\\|\\\\'\\|\\\\a\\|\\\\b\\|\\\\f\\|\\\\n\\|\\\\r\\|\\\\t\\|\\\\v\\|\\\\[0-7]\\{1,3\\}\\|\\\\x[[:xdigit:]][[:xdigit:]]\\)\\|[^\\]\\(?:\\(?1:\\\\u[[:xdigit:]]\\{4\\}\\)\\|\\(?1:\\\\U[[:xdigit:]]\\{8\\}\\)\\|\\(?1:\\\\N{[^z-a]*?}\\)\\)"
     nil re-search-forward t 8 syntax-ppss
     buffer-substring-no-properties 4 -1 string-match]
    14
    ("/nix/store/yvwy8dm26cpa1j12ixgs1dyiaw2abdk9-emacs-snapshot/share/emacs/31.0.50/lisp/progmodes/python.elc"
     . 13774)]
  (1 'font-lock-constant-face t)))

Documentation

Font lock keywords to use in python-mode for maximum decoration.

This decoration level includes everything in python-font-lock-keywords-level-2, as well as constants, decorators, exceptions, and assignments.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defvar python-font-lock-keywords-maximum-decoration
  `((python--font-lock-f-strings)
    ,@python-font-lock-keywords-level-2
    ;; Constants
    (,(rx symbol-start
          (or
           "Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
           ;; copyright, license, credits, quit and exit are added by the site
           ;; module and they are not intended to be used in programs
           "copyright" "credits" "exit" "license" "quit")
          symbol-end)
     . font-lock-constant-face)
    ;; Decorators.
    (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
                                            (0+ "." (1+ (or word ?_)))))
     (1 font-lock-type-face))
    ;; Builtin Exceptions
    (,(rx-to-string `(seq symbol-start
                          (or ,@python-font-lock-builtin-exceptions)
                          symbol-end)) . font-lock-type-face)
    ;; single assignment with/without type hints, e.g.
    ;;   a: int = 5
    ;;   b: Tuple[Optional[int], Union[Sequence[str], str]] = (None, 'foo')
    ;;   c: Collection = {1, 2, 3}
    ;;   d: Mapping[int, str] = {1: 'bar', 2: 'baz'}
    (,(python-font-lock-assignment-matcher
       (python-rx grouped-assignment-target (* space)
                  (? ?: (* space) (group (+ not-simple-operator)) (* space))
                  (group assignment-operator)))
     (1 font-lock-variable-name-face)
     (3 'font-lock-operator-face)
     (,(python-rx symbol-name)
      (progn
        (when-let* ((type-start (match-beginning 2)))
          (goto-char type-start))
        (match-end 0))
      nil
      (0 font-lock-type-face)))
    ;; multiple assignment
    ;; (note that type hints are not allowed for multiple assignments)
    ;;   a, b, c = 1, 2, 3
    ;;   a, *b, c = 1, 2, 3, 4, 5
    ;;   [a, b] = (1, 2)
    ;;   (l[1], l[2]) = (10, 11)
    ;;   (a, b, c, *d) = *x, y = 5, 6, 7, 8, 9
    ;;   (a,) = 'foo'
    ;;   (*a,) = ['foo', 'bar', 'baz']
    ;;   d.x, d.y[0], *d.z = 'a', 'b', 'c', 'd', 'e'
    ;; and variants thereof
    ;; the cases
    ;;   (a) = 5
    ;;   [a] = 5,
    ;;   [*a] = 5, 6
    ;; are handled separately below
    (,(python-font-lock-assignment-matcher
        (python-rx (? (or "[" "(") (* space))
                   grouped-assignment-target (* space) ?, (* space)
                   (* assignment-target (* space) ?, (* space))
                   (? assignment-target (* space))
                   (? ?, (* space))
                   (? (or ")" "]") (* space))
                   (group assignment-operator)))
     (1 font-lock-variable-name-face)
     (2 'font-lock-operator-face)
     (,(python-rx grouped-assignment-target)
      (progn
        (goto-char (match-end 1))       ; go back after the first symbol
        (match-beginning 2))            ; limit the search until the assignment
      nil
      (1 font-lock-variable-name-face)))
    ;; special cases
    ;;   (a) = 5
    ;;   [a] = 5,
    ;;   [*a] = 5, 6
    (,(python-font-lock-assignment-matcher
       (python-rx (or line-start ?\; ?=) (* space)
                  (or "[" "(") (* space)
                  grouped-assignment-target (* space)
                  (or ")" "]") (* space)
                  (group assignment-operator)))
     (1 font-lock-variable-name-face)
     (2 'font-lock-operator-face))
    ;; Operators.
    (,(python-rx operator) . 'font-lock-operator-face)
    ;; escape sequences within bytes literals
    ;;   "\\" "\'" "\a" "\b" "\f" "\n" "\r" "\t" "\v"
    ;;   "\ooo" character with octal value ooo
    ;;   "\xhh" character with hex value hh
    (,(python--string-bytes-literal-matcher
       (python-rx bytes-escape-sequence)
       python--not-raw-bytes-literal-start-regexp)
     (1 font-lock-constant-face t))
    ;; escape sequences within string literals, the same as appear in bytes
    ;; literals in addition to:
    ;;   "\uxxxx" Character with 16-bit hex value xxxx
    ;;   "\Uxxxxxxxx" Character with 32-bit hex value xxxxxxxx
    ;;   "\N{name}" Character named name in the Unicode database
    (,(python--string-bytes-literal-matcher
       (python-rx string-escape-sequence)
       python--not-raw-string-literal-start-regexp)
     (1 'font-lock-constant-face t)))
  "Font lock keywords to use in `python-mode' for maximum decoration.

This decoration level includes everything in
`python-font-lock-keywords-level-2', as well as constants,
decorators, exceptions, and assignments.")