GNU bug report logs - #69357
[PATCH] Improve fontification of Python assignment statement with type hints

Previous Next

Package: emacs;

Reported by: kobarity <kobarity <at> gmail.com>

Date: Sat, 24 Feb 2024 14:25:02 UTC

Severity: normal

Tags: patch

Fixed in version 30.1

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 69357 in the body.
You can then email your comments to 69357 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#69357; Package emacs. (Sat, 24 Feb 2024 14:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to kobarity <kobarity <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 24 Feb 2024 14:25:03 GMT) Full text and rfc822 format available.

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

From: kobarity <kobarity <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Improve fontification of Python assignment statement with
 type hints
Date: Sat, 24 Feb 2024 23:23:27 +0900
[Message part 1 (text/plain, inline)]
In python-mode (not python-ts-mode), "List" in the type hints of the
following code are fontified as variable names.

#+begin_src python
a: List[List[CustomInt], List[CustomInt]] = []
#+end_src

This is due to misinterpretation as a multiple assignment statement
such as:

#+begin_src python
a, b = 1, 2
#+end_src

To address this issue and to improve fontification, I suggest to
fontify type hints in the assignment statement as type names before
processing multiple assignment statements, as in the attached patch.

--
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw scroll bars) of 2024-02-24 built on ubuntu
Repository revision: eeb89a5cb292bffe40ba7d0b0cf81f82f8452bf8
Repository branch: master
System Description: Ubuntu 22.04.4 LTS
[0001-Improve-fontification-of-Python-assignment-statement.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69357; Package emacs. (Sat, 18 May 2024 20:25:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: kobarity <kobarity <at> gmail.com>, 69357 <at> debbugs.gnu.org
Subject: Re: bug#69357: [PATCH] Improve fontification of Python assignment
 statement with type hints
Date: Sat, 18 May 2024 20:23:24 +0000
close 69357 30.1
thanks

kobarity <kobarity <at> gmail.com> writes:

> In python-mode (not python-ts-mode), "List" in the type hints of the
> following code are fontified as variable names.
>
> #+begin_src python
> a: List[List[CustomInt], List[CustomInt]] = []
> #+end_src
>
> This is due to misinterpretation as a multiple assignment statement
> such as:
>
> #+begin_src python
> a, b = 1, 2
> #+end_src
>
> To address this issue and to improve fontification, I suggest to
> fontify type hints in the assignment statement as type names before
> processing multiple assignment statements, as in the attached patch.

Your analysis seems correct, and the fix works here.  It's very nice to
see tests for this too, as always.

Thus, I've now pushed your change to master (commit c97e7a2da2e).
I'm consequently closing this bug report.

Thanks for your contribution!




bug marked as fixed in version 30.1, send any further explanations to 69357 <at> debbugs.gnu.org and kobarity <kobarity <at> gmail.com> Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 18 May 2024 20:25:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Jun 2024 11:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 18 days ago.

Previous Next


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