GNU bug report logs - #71797
30.0.60; Face of variables and function parameters in Python

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71797 in the body.
You can then email your comments to 71797 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#71797; Package emacs. (Thu, 27 Jun 2024 14:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Jun 2024 14:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.60; Face of variables and function parameters in Python
Date: Thu, 27 Jun 2024 16:04:58 +0200
[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)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71797; Package emacs. (Fri, 28 Jun 2024 05:52:03 GMT) Full text and rfc822 format available.

Message #8 received at 71797 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Stephen Berman <stephen.berman <at> gmx.net>, 71797 <at> debbugs.gnu.org
Subject: Re: bug#71797: 30.0.60; Face of variables and function parameters in
 Python
Date: Fri, 28 Jun 2024 04:01:40 +0300
On 27/06/2024 17:04, Stephen Berman via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> 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.

That seems all right: in all of these cases the variable is being 
introduced, aren't they?

python-mode doesn't have access to a parser of the same quality, so we 
shouldn't expect the exact same features.




Added tag(s) notabug. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 01 Mar 2025 01:56:01 GMT) Full text and rfc822 format available.

Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 01 Mar 2025 01:56:02 GMT) Full text and rfc822 format available.

Notification sent to Stephen Berman <stephen.berman <at> gmx.net>:
bug acknowledged by developer. (Sat, 01 Mar 2025 01:56:02 GMT) Full text and rfc822 format available.

Message #15 received at 71797-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 71797-done <at> debbugs.gnu.org, Stephen Berman <stephen.berman <at> gmx.net>
Subject: Re: bug#71797: 30.0.60;
 Face of variables and function parameters in Python
Date: Fri, 28 Feb 2025 17:55:15 -0800
Dmitry Gutov <dmitry <at> gutov.dev> writes:

> On 27/06/2024 17:04, Stephen Berman via Bug reports for GNU Emacs, the Swiss
> army knife of text editors wrote:
>> 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.
>
> That seems all right: in all of these cases the variable is being introduced,
> aren't they?
>
> python-mode doesn't have access to a parser of the same quality, so we shouldn't
> expect the exact same features.

Agreed, I don't think we can expect python-mode to have exactly the same
behavior in all cases.  So this doesn't look like a bug to me.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Mar 2025 11:24:50 GMT) Full text and rfc822 format available.

This bug report was last modified 99 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.