GNU bug report logs -
#71797
30.0.60; Face of variables and function parameters in Python
Previous Next
Reported by: Stephen Berman <stephen.berman <at> gmx.net>
Date: Thu, 27 Jun 2024 14:06:01 UTC
Severity: normal
Tags: notabug
Found in version 30.0.60
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
0. emacs -Q, where Emacs has been built with treesitter support and the
treesitter Python grammar library is installed.
1. Visit the attached file "test.py", which contains examples in Python
of variables and function parameters with type hints. The buffer is
now in the default (non-treesitter) python-mode.
2. Notice that the initialized annotated variable `age' and the
(unannotated) assigned to occurrences of `child' are fontified with
font-lock-variable-name-face, while the uninitialized annotated
variables `a' and `child' and the annotated function parameters
`num', `num1' and `num2' are displayed in the default face.
3. M-x python-ts-mode. Now the uninitialized `age', `a' and `child' as
well as the function parameters `num', `num1' and `num2' are all
fontified with font-lock-variable-name-face.
I don't know if this difference demonstrates a bug in python-mode or in
python-ts-mode, but I assume only one of them is right. I note that in
much online Python documentation variables in assignments or function
parameters (with or without type hints) are mostly not fontified
(e.g. in Python's own documentation and in
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html, which is
where the examples in the attached file come from). On the other hand,
I note that python-ts-mode also fontifies function parameters that lack
type hints or default values with font-lock-variable-name-face (the
default python-mode does not).
In GNU Emacs 30.0.60 (build 3, x86_64-pc-linux-gnu, GTK+ Version
3.24.42, cairo version 1.18.0) of 2024-06-26 built on strobelfs
Repository revision: 1809f6a93efe0ab3ac0f62743c92bd90860ff3ea
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Linux From Scratch r12.1-85
Configured using:
'configure -C 'CFLAGS=-Og -g3''
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
[test.py (application/octet-stream, attachment)]
This bug report was last modified 160 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.