GNU bug report logs -
#54992
29.0.50; python.el: custom type hint in assignment statements is font-locked as a variable
Previous Next
Reported by: kobarity <kobarity <at> gmail.com>
Date: Sun, 17 Apr 2022 15:58:01 UTC
Severity: normal
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
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 54992 in the body.
You can then email your comments to 54992 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
dario.gjorgjevski <at> gmail.com, bug-gnu-emacs <at> gnu.org
:
bug#54992
; Package
emacs
.
(Sun, 17 Apr 2022 15:58: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
dario.gjorgjevski <at> gmail.com, bug-gnu-emacs <at> gnu.org
.
(Sun, 17 Apr 2022 15:58:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
X-Debbugs-CC: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Hi,
This is a separation of bugs mentioned in #51362 Message #24.
When the following file is loaded using emacs -Q and M-x find-file,
CustomInt in the last line is font-locked as a variable name.
#+begin_src python
from typing import List
CustomInt = int
YS: List[CustomInt] = []
#+end_src
Type hints should not be highlighted as variable names.
This is caused by the font-lock rule for special cases of assignment
statements such as '[a] = 5,'. I suggest applying the following patch
to restrict the rule not to match type hints.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index c4d8b123a8..f355055806 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -706,7 +706,8 @@ python-font-lock-keywords-maximum-decoration
;; [a] = 5
;; [*a] = 5, 6
(,(python-font-lock-assignment-matcher
- (python-rx (or "[" "(") (* space)
+ (python-rx (or line-start ?\;) (* space)
+ (or "[" "(") (* space)
grouped-assignment-target (* space)
(or ")" "]") (* space)
assignment-operator))
In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu)
of 2022-04-16 built on ubuntu
Repository revision: db416ae04982d7cf5c6af463d0c47c902f8d9119
Repository branch: master
System Description: Ubuntu 21.10
Configured using:
'configure --without-x --with-gnutls=ifavailable'
Configured features:
ACL LIBXML2 MODULES NOTIFY INOTIFY PDUMPER SECCOMP SOUND SQLITE3 THREADS
XIM ZLIB
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow regexp-opt sort mail-extr emacsbug message mailcap yank-media
rmc puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa
derived epg rfc6068 epg-config gnus-util text-property-search time-date
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils term/screen term/xterm xterm seq gv subr-x
byte-opt bytecomp byte-compile cconv iso-transl tooltip eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
nadvice simple cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
faces cus-face macroexp files window text-properties overlay sha1 md5
base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads inotify multi-tty
make-network-process emacs)
Memory information:
((conses 16 45429 6400)
(symbols 48 5661 1)
(strings 32 15693 1667)
(string-bytes 1 499770)
(vectors 16 8641)
(vector-slots 8 104321 5828)
(floats 8 23 236)
(intervals 56 202 0)
(buffers 992 11))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54992
; Package
emacs
.
(Sun, 17 Apr 2022 17:29:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 54992 <at> debbugs.gnu.org (full text, mbox):
kobarity <kobarity <at> gmail.com> writes:
> This is caused by the font-lock rule for special cases of assignment
> statements such as '[a] = 5,'. I suggest applying the following patch
> to restrict the rule not to match type hints.
Makes sense to me; pushed to Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
54992 <at> debbugs.gnu.org and kobarity <kobarity <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sun, 17 Apr 2022 17:29:01 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
.
(Mon, 16 May 2022 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 95 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.