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.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#71797: closed (30.0.60; Face of variables and function
 parameters in Python)
Date: Sat, 01 Mar 2025 01:56:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 28 Feb 2025 17:55:15 -0800
with message-id <CADwFkmkFDSQVuaoVQxgm2obdECSEUri41PFBD1iSKOj4u9fZxQ <at> mail.gmail.com>
and subject line Re: bug#71797: 30.0.60; Face of variables and function parameters in Python
has caused the debbugs.gnu.org bug report #71797,
regarding 30.0.60; Face of variables and function parameters in Python
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
71797: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71797
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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 3 (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)]
[Message part 5 (message/rfc822, inline)]
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.


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.