From unknown Mon Jun 16 23:47:54 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#45348 <45348@debbugs.gnu.org> To: bug#45348 <45348@debbugs.gnu.org> Subject: Status: 27.1; python-eldoc-setup-code uses obsolete python function Reply-To: bug#45348 <45348@debbugs.gnu.org> Date: Tue, 17 Jun 2025 06:47:54 +0000 retitle 45348 27.1; python-eldoc-setup-code uses obsolete python function reassign 45348 emacs submitter 45348 Steven De Herdt severity 45348 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 20 18:20:44 2020 Received: (at submit) by debbugs.gnu.org; 20 Dec 2020 23:20:44 +0000 Received: from localhost ([127.0.0.1]:45770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kr80K-00081i-8n for submit@debbugs.gnu.org; Sun, 20 Dec 2020 18:20:44 -0500 Received: from lists.gnu.org ([209.51.188.17]:53870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kr80I-00081Z-Gu for submit@debbugs.gnu.org; Sun, 20 Dec 2020 18:20:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kr80I-0001yT-B7 for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2020 18:20:42 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kr80G-0002YM-2t for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2020 18:20:42 -0500 Received: by mail-wr1-x42d.google.com with SMTP id t30so9130676wrb.0 for ; Sun, 20 Dec 2020 15:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:subject:from:message-id:date:user-agent:mime-version :content-language; bh=XWQ+vUdy5b/V00MXtCE+3fxmTUN+9XfvfKrWH25S4OU=; b=bIeUapIcw1d/8p1W8TFW67XUy2gbKANGJHy8UC8CoRS0aWsH+PQxdw7ymtWTMgvweS HG08l9kT72NH4zUtopHD6ZweBiVX9tTf0gdny0wvw9ckuMWdLlCLqdiE1yv1E2xPDnwx d+Xa07743oqOON+39hnwGViCG78sGTWy9LYul0p7VbGdSgn0V6OKgXVgmGxKK/LGJ8bd isY4xA7YZumUWstVio5EfFTNqAhAw8sCkvBYkgLTx1vMMdIP+0qsk0C8rXmapITUFRP0 eotbVQy33MgPs7sf/kHfYTSgd8N9Edq6mzih5RznGXOYBY1y1jbGtOZ8NwkOwdzpQymb qTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:from:message-id:date:user-agent :mime-version:content-language; bh=XWQ+vUdy5b/V00MXtCE+3fxmTUN+9XfvfKrWH25S4OU=; b=s5ujOfOKIuAU0umcZDqodI4bwBfc0I2Ku/a2jQPZN1KkWvrDUYKWMwxdXlU4Uewbu3 ChBYq16ACY3pyL63FjR/TqyIo4ctTt2PmhQz0lHAk4tGmjXg9psWaqGZjb80W4dhXPNY ObU4MW1T1ZfKf1+UWvA4imz++tSjWrGRCilw6I3JAYmt6vSpQ8hLeQfsL3L5U5bb+y7/ Np14i80JywgYLSDsKvpeAml/27W4s+HyYlYVwy0CcoOjF8kePyXKaoLuVARSVxrkWeaT qRDuX5KioaFo60tiFd72qdnCSOEe8g2Wu0JbZIhp04AtkHx8IrNJNgKVXCVfcgjVQHAM hADQ== X-Gm-Message-State: AOAM53010EdTNbtKBJXSSpUMiMLJHzoL9ZOGb6HAGtW56je/EkGfYuOV q4JWQdksORkuItHiYkZ7mqUlEQt5gGA= X-Google-Smtp-Source: ABdhPJxYMlVdPXAHW5ILq0JKMnQSIkVcICc+EAL1xt+rnLzz9XrED92ink544S73z+U/EuucwFVcTQ== X-Received: by 2002:a5d:4683:: with SMTP id u3mr15730249wrq.19.1608506437875; Sun, 20 Dec 2020 15:20:37 -0800 (PST) Received: from localhost (ip-213-49-204-145.dsl.scarlet.be. [213.49.204.145]) by smtp.googlemail.com with ESMTPSA id w3sm21992842wma.3.2020.12.20.15.20.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Dec 2020 15:20:36 -0800 (PST) To: bug-gnu-emacs@gnu.org Subject: 27.1; python-eldoc-setup-code uses obsolete python function From: Steven De Herdt Message-ID: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> Date: Mon, 21 Dec 2020 00:20:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4C842321002D38B59E2AC08F" Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=steven.deherdt@gmail.com; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------4C842321002D38B59E2AC08F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hello folks This report concerns eldoc for Python. I'm using Debian testing, with Python 3.9, in my daily config I use ipython3 as python-shell-interpreter. Every time I place point in the argument list of a Python function without documentation, the minibuffer expands to show a warning ("DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly"), an unrelated snippet of my code, as well as the intended function signature. This behaviour can be partly reproduced in a minimal setting with the attached func.py: * emacs -Q func.py * C-u C-c C-p , choose "python3 -i" * in buffer for func.py: C-c C-c * place point at argument (13) of the call to func The DeprecationWarning only shows the first time with python3. My ipython3 shows it every time however, that's a bit annoying. I'm not sure the repeated warning is an issue with ipython, but the eldoc setup code would need to upgrade from deprecated functionality anyway. Maybe I'll try to make python-eldoc-setup-code use inspect.signature if it annoys me too much. :) Thanks for all the emacs! -Steven In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0) of 2020-11-08, modified by Debian built on x86-ubc-01 Windowing system distributor 'The X.Org Foundation', version 11.0.12010000 System Description: Debian GNU/Linux bullseye/sid Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Mark set Make dedicated process? (y or n) y Shell native completion is enabled. Can’t guess python-indent-offset, using defaults: 4 Sent: #! /usr/bin/python3... Mark set user-error: Beginning of history; no preceding item user-error: End of history; no default available Configured using: 'configure --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd --with-pop=yes --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp --with-sound=alsa --without-gconf --with-mailutils --with-cairo --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs-6jKC2B/emacs-27.1+1=. -fstack-protector-strong -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP Important settings: value of $LC_TIME: nl_BE.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils thingatpt compile cl-extra help-mode python easymenu tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete parse-time iso8601 time-date ls-lisp format-spec auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map seq byte-opt gv bytecomp byte-compile cconv comint ring cl-loaddefs cl-lib ansi-color tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 75346 9259) (symbols 48 8919 1) (strings 32 26350 2263) (string-bytes 1 947097) (vectors 16 15081) (vector-slots 8 187151 10066) (floats 8 55 29) (intervals 56 274 0) (buffers 1000 15)) --------------4C842321002D38B59E2AC08F Content-Type: text/x-python; charset=UTF-8; name="func.py" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="func.py" #! /usr/bin/python3 def func(a): return 15*a func(13) --------------4C842321002D38B59E2AC08F-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 23 18:53:50 2020 Received: (at 45348) by debbugs.gnu.org; 23 Dec 2020 23:53:50 +0000 Received: from localhost ([127.0.0.1]:54395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ksDwz-0007sn-Ok for submit@debbugs.gnu.org; Wed, 23 Dec 2020 18:53:50 -0500 Received: from mout02.posteo.de ([185.67.36.66]:43945) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ksDww-0007sT-8q for 45348@debbugs.gnu.org; Wed, 23 Dec 2020 18:53:47 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 92A0A2400FB for <45348@debbugs.gnu.org>; Thu, 24 Dec 2020 00:53:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1608767619; bh=nHkhR7bIUtpD5pKOlucvjUhB1/1aZCC3R6+B6BxPe0o=; h=From:To:Subject:Date:From; b=Xkq2cwBIkg/8cwxoAgp49hpp4ky0vjq7IfkPMZSU6M3p+hw5bSWqrvBLvQ5s3nc+r fnsgnZT3UnZd9X2MvtY03SSWzG5Ikkc8VbxR51GZRk22+Xr0nJr/kshAzpjNBBsIax DHpKQINWX7n9WrE8bC924hnjn902+Lo0J7s0R+hZ5276V3lkGeVugsd6C14VLAPEqz ZzmoMziJYiuWapBBYXPI3p8KNY9N8jt7jOtPRJVPnqPTDI77OMSkIN+J3AS6sNmSvu np54DWiK0XMLabiuOGYOuYYaQVDzANmCFqR62CDqF6yeKJFUsuBCgWwkfEWneLI+t9 zVn0sONG/48hg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4D1VQp6CXbz9rxP; Thu, 24 Dec 2020 00:53:38 +0100 (CET) From: Tomas Nordin To: Steven De Herdt , 45348@debbugs.gnu.org Subject: Re: bug#45348: 27.1; python-eldoc-setup-code uses obsolete python function In-Reply-To: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> References: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> Date: Thu, 24 Dec 2020 00:53:38 +0100 Message-ID: <877dp8dqpp.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45348 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Steven De Herdt writes: > Hello folks > > This report concerns eldoc for Python. I'm using Debian testing, with > Python 3.9, in my daily config I use ipython3 as > python-shell-interpreter. Every time I place point in the argument list > of a Python function without documentation, the minibuffer expands to > show a warning ("DeprecationWarning: `formatargspec` is deprecated since > Python 3.5. Use `signature` and the `Signature` object directly"), an > unrelated snippet of my code, as well as the intended function signature. > > This behaviour can be partly reproduced in a minimal setting with the > attached func.py: > * emacs -Q func.py > * C-u C-c C-p , choose "python3 -i" > * in buffer for func.py: C-c C-c > * place point at argument (13) of the call to func > The DeprecationWarning only shows the first time with python3. My > ipython3 shows it every time however, that's a bit annoying. I'm not > sure the repeated warning is an issue with ipython, but the eldoc setup > code would need to upgrade from deprecated functionality anyway. I can reproduce this with Python 3.7.3 on Debian stable. And yes, strange behaviour with Ipython, which is maybe not about the eldoc setup code. > Maybe I'll try to make python-eldoc-setup-code use inspect.signature if > it annoys me too much. :) Yes, did you figure out something safe and sound? Otherwise can you please try the attached patch. It fixes the problem here. The patch touch the string of python code `python-eldoc-setup-code' and do a little more than simply not call formatargspec with python 3, but does not change the intended effect. I think the patch improves readability somewhat. But also I identified a few bugs with the python code in the string. Those bugs doesn't surface due to the (needed) wrapping try block. Here are the observed bugs, - if obj is not a string, if isinstance(obj, str_type) fails and doc does not get defined. After this, doc is referred to in the next test, (if not doc and callable(obj):) which will then error. - if obj is a class instance and has an empty docstring and is not callable (often not), then (if not doc and callable(obj)) fails and doc.splitlines()[0] will Error. - again, if obj is a class instance, not callable but has no docstring, doc will be None and doc.splitlines() will error. - if obj is provided as the object itself, the function always fail because doc does not get defined. Those bugs are fixed with the patch, as well as using inspect.signature with python 3 as recommended by the deprecation warning. Besides the patch, I wonder what other users thinks about the resulting behaviour of this python function. Here is a a suitable docstring for `python-eldoc-setup-code', would it be provided: """Provide a docstring or signature on obj. Prefer a docstring, and fall back on the signature if no docstring is found.""" Meaning, if there is a docstring, we will not get the call signature, we get that only when there is no docstring. Personally I would prefer the call signature always, like in elisp. Then perhaps when doing C-c C-f (python-eldoc-at-point) show the (full) docstring. But that would be another bug-report I guess. Best regards -- Tomas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=pydoc-45348.patch diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d58b32f3c3..6acfafdb68 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4533,33 +4533,35 @@ python-eldoc-setup-code "def __PYDOC_get_help(obj): try: import inspect + from sys import version_info as version_info + try: - str_type = basestring - argspec_function = inspect.getargspec - except NameError: - str_type = str - argspec_function = inspect.getfullargspec - if isinstance(obj, str_type): obj = eval(obj, globals()) - doc = inspect.getdoc(obj) + doc = inspect.getdoc(obj) + except TypeError: + doc = inspect.getdoc(obj) + if not doc and callable(obj): - target = None if inspect.isclass(obj) and hasattr(obj, '__init__'): target = obj.__init__ objtype = 'class' else: target = obj objtype = 'def' - if target: - args = inspect.formatargspec(*argspec_function(target)) - name = obj.__name__ - doc = '{objtype} {name}{args}'.format( - objtype=objtype, name=name, args=args - ) - else: + if version_info.major == 3: + args = str(inspect.signature(target)) + else: + args = inspect.formatargspec(*inspect.getargspec(target)) + + name = obj.__name__ + doc = '{objtype} {name}{args}'.format( + objtype=objtype, name=name, args=args) + elif doc: doc = doc.splitlines()[0] + else: + doc = '' except: - doc = '' + return '' return doc" "Python code to setup documentation retrieval." :type 'string --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 25 16:41:33 2020 Received: (at 45348) by debbugs.gnu.org; 25 Dec 2020 21:41:34 +0000 Received: from localhost ([127.0.0.1]:58311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ksuq5-00012O-Lo for submit@debbugs.gnu.org; Fri, 25 Dec 2020 16:41:33 -0500 Received: from mail-il1-f171.google.com ([209.85.166.171]:36846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ksuq3-00011w-Gm for 45348@debbugs.gnu.org; Fri, 25 Dec 2020 16:41:32 -0500 Received: by mail-il1-f171.google.com with SMTP id u12so4704637ilv.3 for <45348@debbugs.gnu.org>; Fri, 25 Dec 2020 13:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UcclR6bGZNS86a54SkEGtV7hYC/WBObgtIb5c9NfHOI=; b=KFy1D2TyOdt1WFC5zrXSOxnUv6UaUpfZrorQ9B1IGhnM5mpaCPZhFWCRPIxZve0s5L 5ai2Pt4xmgLny5EcUYXLxRaCctGe43vheYqI24vxXKgoac3RC6cE18371/7IMNluId1s xB5vGi2XWTjQny/VpG+yfPmmLDlW1Vg1XDBm9fSQ7TQ9NTjwmr/O/SIjsZ8g+nnrHncw gp/KvDwi+BKlHsx/ghl1q9zJ+0mvYZVbJ80QJsHVyBORZStoasBVPvOPyJYsxHrhqGlK ZgsVeUDIVDA/+C4Hb2ziUpihoBlwdtYxA9sgd29Uyqd+BQlLwxpFEDAAC1cULAmLs3WR 73Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UcclR6bGZNS86a54SkEGtV7hYC/WBObgtIb5c9NfHOI=; b=TPvG8yk1tC8Z3FpE8GfRNAqPXcnfPlgc0ziqpv2vQ3W12lRqkYljPN+DSN2nRwxIu9 IhB1ikUoHw4BT+RkgckmPIDYJovWkti3WwiDSg1iN4QX6CXCHlY3qBpxWjepS9LeToDS N7ZSs7c2xWzAOUQp5Swj3xgth4w8MQ+Fb2UpJhZ77luqArIMSUO3zeSKLAkj2je9CWZ5 MpxkMPQS2MM45S9wbUcwOtL4DWKR4ff8vDljisJtz1nPbJbOvPgq/cSL+ySM6A0XydZp hvDrnuqA0QsodzhZHpQe6PgiChhzvyrZT4q2yPFoBRgB8cD1NckpginhqBxZvIBqDOJr Gb3A== X-Gm-Message-State: AOAM532tgfJmpJT1B2ihIswCe/kmKwu+gTlG4c/hM0HfmTA6eZv2+J0J HNkGciXyHjLydg1SEbT3/8p7W0VPDCgqExcAfBo= X-Google-Smtp-Source: ABdhPJxJgtcpi0WkK8frMKpTQFPrIFQJX/b6ocMWJbCHHi1OFcUdaZ3mXT7AuMGdPPInKRVOYo1KYL4tEy2COSdPvv8= X-Received: by 2002:a05:6e02:14ce:: with SMTP id o14mr34773334ilk.9.1608932485711; Fri, 25 Dec 2020 13:41:25 -0800 (PST) MIME-Version: 1.0 References: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> <877dp8dqpp.fsf@posteo.net> In-Reply-To: <877dp8dqpp.fsf@posteo.net> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 25 Dec 2020 21:41:13 +0000 Message-ID: Subject: Re: bug#45348: 27.1; python-eldoc-setup-code uses obsolete python function To: Tomas Nordin Content-Type: multipart/alternative; boundary="000000000000474bc005b750c9a3" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45348 Cc: Steven De Herdt , 45348@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000474bc005b750c9a3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 23, 2020, 23:54 Tomas Nordin wrote: > > Meaning, if there is a docstring, we will not get the call signature, > we get that only when there is no docstring. Personally I would prefer > the call signature always, like in elisp. Then perhaps when doing C-c > C-f (python-eldoc-at-point) show the (full) docstring. But that would be > another bug-report I guess. > If you think you can program this, the latest ElDoc allows you to do just that. See the docstrings of eldoc-documentation-functions, eldoc-documentation-strategy, eldoc-display-functions and other variables prefixed eldoc-echo-area. Also see the new interactive command M-x eldoc. All of those things have been touched recently by me, and I'd appreciate the feedback. Jo=C3=A3o Jo=C3=A3o > --000000000000474bc005b750c9a3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Dec 23, 2020, 23:54 Tomas Nordin <tomasn@posteo.net> wrote:

Meaning, if there is a docstring, we will not get the call signature,
we get that only when there is no docstring. Personally I would prefer
the call signature always, like in elisp. Then perhaps when doing C-c
C-f (python-eldoc-at-point) show the (full) docstring. But that would be another bug-report I guess.
<= br>
If you think you can program this, the latest El= Doc allows you to do just that. See the docstrings of eldoc-documentation-f= unctions, eldoc-documentation-strategy, eldoc-display-functions and other v= ariables prefixed eldoc-echo-area. Also see the new interactive command M-x= eldoc.

All of those thi= ngs have been touched recently by me, and I'd appreciate the feedback.<= /div>

Jo=C3=A3o

Jo=C3=A3o
--000000000000474bc005b750c9a3-- From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 11:19:49 2020 Received: (at 45348) by debbugs.gnu.org; 28 Dec 2020 16:19:49 +0000 Received: from localhost ([127.0.0.1]:36586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvFN-0003Us-7R for submit@debbugs.gnu.org; Mon, 28 Dec 2020 11:19:49 -0500 Received: from mout01.posteo.de ([185.67.36.65]:58916) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvFK-0003Ua-2n for 45348@debbugs.gnu.org; Mon, 28 Dec 2020 11:19:48 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 783DE160061 for <45348@debbugs.gnu.org>; Mon, 28 Dec 2020 17:19:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1609172379; bh=aqdVr1KB22tFOB8NMRWHwu5b90xQov36O1+4pF2fh6c=; h=From:To:Cc:Subject:Date:From; b=YZ+/cuvhlEqAMFYfYKJrKwU/ldkarBGWFyRJtUslKEGqWlDC3PRVg6hjyOqwe1+Fh e7SYx63FmxK5d3nrvdb3Om47KIds+KOdd3sLQmgYSzqnzqRNV9fXLHSvfZ4Vknz/BQ N9pu1jhN5c++ORyXgnDgZE9GX/mSI7gD3YQ1bFacE2MZxKmVbm5p+cSnlV1xL/c80G FMCsXHo3EIVLHV6uYMrZeds5vM9aOs8WXwZ9A1cU9+KLu11t/ikHb6dSpbMUwWBjQ2 kZBnc2hx9giT/KvTxK0fLT5/tuRvTG78Z3aQMZrPvTpy+DKt57eJ7rsRS4pVQa6lLm DZ0vqkSV00j9w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4D4N6f5SSfz6tmL; Mon, 28 Dec 2020 17:19:38 +0100 (CET) From: Tomas Nordin To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#45348: 27.1; python-eldoc-setup-code uses obsolete python function In-Reply-To: References: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> <877dp8dqpp.fsf@posteo.net> Date: Mon, 28 Dec 2020 17:19:38 +0100 Message-ID: <87zh1x6gyt.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45348 Cc: Steven De Herdt , 45348@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Jo=C3=A3o T=C3=A1vora writes: > On Wed, Dec 23, 2020, 23:54 Tomas Nordin wrote: > >> >> Meaning, if there is a docstring, we will not get the call signature, >> we get that only when there is no docstring. Personally I would prefer >> the call signature always, like in elisp. Then perhaps when doing C-c >> C-f (python-eldoc-at-point) show the (full) docstring. But that would be >> another bug-report I guess. >> > > If you think you can program this, the latest ElDoc allows you to do just > that. See the docstrings of eldoc-documentation-functions, > eldoc-documentation-strategy, eldoc-display-functions and other variables > prefixed eldoc-echo-area. Also see the new interactive command M-x eldoc. > > All of those things have been touched recently by me, and I'd appreciate > the feedback. OK, thanks. Then we know the API to read up on when it comes to that. I would be happy to try and help improving the doc support in python.el. The strategy I would suggest to do that would be -- C-c C-d python-describe-at-point Make this display full documentation akin to C-h f in elisp. Document this function to do so, currently it is un-documented. And current effect is to leave the help text in the python shell, which works sometimes. -- C-c C-f python-eldoc-at-point Make this output the first line of docstring, if there is no docstring show nothing. This is almost what happens now, only if there is no docstring the signature is given instead. -- Automatic help display of objects Make this show signatures always. (akin to elisp mode). But I don't know if anybody care to see this happen. Best regards -- Tomas From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 18:59:06 2020 Received: (at 45348) by debbugs.gnu.org; 28 Dec 2020 23:59:06 +0000 Received: from localhost ([127.0.0.1]:37184 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku2Pq-0002Ib-Ep for submit@debbugs.gnu.org; Mon, 28 Dec 2020 18:59:06 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:40108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku2Pl-0002I1-Id for 45348@debbugs.gnu.org; Mon, 28 Dec 2020 18:59:05 -0500 Received: by mail-wr1-f48.google.com with SMTP id 91so12748924wrj.7 for <45348@debbugs.gnu.org>; Mon, 28 Dec 2020 15:59:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=wIWE7++fuWnM03ZxEBEwq2IwJ3TVXwdAjLhAkFVg19M=; b=jN/ahT95l+2kkLeMLzex9ykmvHwxZlKuu+y42y+Oyw3zVHHG5zXWhJj+lWCucFFQ7H Fs+e7dImDm3E3KUGcYYUe5z28LZDaQe+Sel3NR7uNfhGZOF4hKrLAJgYXKpATkmammUr Fk8LHCkECIl9xDYCUxII8dwRXU9+vARxhyG3w937bwlbCJJkpXBGWNMzT1gglBCjSiGw xgrwg9Oc9G/E2sQCYygb7l1Mnl2+YmxKv9gYyoytiMMOOuQg0ZddDYKXiWCpNVefQ+0o WoGGcfX3gYapba2jdDolypocF02z2N0O9pj6TUS6NvbZ8t91KYDZR8rEWLc1tPMQT3+l wgKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=wIWE7++fuWnM03ZxEBEwq2IwJ3TVXwdAjLhAkFVg19M=; b=Js/V1mrZ5NGn5qY5ANPlsDwiCauJnHTJmOKneRoI+37k7sf4hKrPgFnSDKHks80HIM ptTHB1aBVkjrA9ZLsCtX+nHbTMfROf6lEQAD6zE7hiS1C/xpJYzyg3o3mRDcL30xjCgb Djje5lzZqhUeK9jed+Nn7u+Y/lz57zHsyg1RdR/XgDqxgob645m8zlPuj4I+wW7pUUJz J2LEj3HEPjqcfW6Rg/2gqorayRS8G3BKAjlUpo9D92dlDzp7VNaQrRDubt/ZbDQcTBlj B0n821pwpAAAJB2FFtjEDSlM2aC1gyuq1L2XdqL841SiMMXCBUFi15VsO5uX87zvEnqQ M9Vw== X-Gm-Message-State: AOAM531xNETQmKFcIYivB9YFpXeE7Icr8mPaIWpPw/t/p6bODL14DL4I whpkHCNy3Hvtws27Z9Tm0j0= X-Google-Smtp-Source: ABdhPJzebCoaWRPcJCyFLQMfxWh+yEs8p0x+9XUlrTI1nDJL5NuHkX5j0/HmywnGkA9UKNtjlCyU9w== X-Received: by 2002:a5d:61c4:: with SMTP id q4mr53336705wrv.304.1609199935621; Mon, 28 Dec 2020 15:58:55 -0800 (PST) Received: from krug ([89.180.149.164]) by smtp.gmail.com with ESMTPSA id h83sm1149838wmf.9.2020.12.28.15.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 15:58:54 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Tomas Nordin Subject: Re: bug#45348: 27.1; python-eldoc-setup-code uses obsolete python function References: <197a8432-07fd-4639-e504-0fde30d3f088@gmail.com> <877dp8dqpp.fsf@posteo.net> <87zh1x6gyt.fsf@posteo.net> Date: Mon, 28 Dec 2020 23:58:53 +0000 In-Reply-To: <87zh1x6gyt.fsf@posteo.net> (Tomas Nordin's message of "Mon, 28 Dec 2020 17:19:38 +0100") Message-ID: <87pn2tiite.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45348 Cc: Steven De Herdt , 45348@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Tomas Nordin writes: >> All of those things have been touched recently by me, and I'd appreciate >> the feedback. > > OK, thanks. Then we know the API to read up on when it comes to that. > > I would be happy to try and help improving the doc support in python.el. > The strategy I would suggest to do that would be > > -- C-c C-d python-describe-at-point > > Make this display full documentation akin to C-h f in elisp. Document > -- Automatic help display of objects > > Make this show signatures always. (akin to elisp mode). > > But I don't know if anybody care to see this happen. I would. Or at least I think these ideas are welcome input for solving the broader problem of inconsistency of documentation systems in Emacs. In fact, I'm going to take this opportunity to lay out a plan that I've been thinking of, to collect some early feedback, and to seize on any motivation that you or someone else may have to work on this. I quite agree with you when you say there is something that should display full documentation akin to C-h f in Elisp. But this is not only for Python, it is for all languages -- including Elisp. In my opinion, that something should be 'M-x eldoc' (and we can chose a prominent shortcut for it later). In the latest Emacs, when invoked interactively, it pops up a new buffer (like C-h f does) which contains detailed information about how to use a particular element of the language (a function, a procedure, a variable, etc). When invoked automatically by a background process, it behaves more discreetly, but and normally displays a shorter string in the echo area. Under the hood, the ElDoc framework also now possesses the main tools to help segregate succint short summaries that can be shown in a constrained setting -- such as the echo area -- from longer descriptions that are more suitable for larger outlets, such as buffers, separate frame and long-winded popup widgets. These tools are the aforementioned eldoc-documentation-functions and eldoc-display-functions. In my view we're only missing a protocol for the former to communicate to the latter how small or large the produces pieces of documentation are. How? Here's the current situation in Elisp mode: M-x eldoc will call on one or two backends (sometimes both, depending on eldoc-documentation-strategy) to document the thing at point: the variable documentation one and the function documentation one. For historical reasons, they return simple one liners for displaying in the echo area. But each could _additionally_ return much richer descriptions like the ones that C-h v and C-h f do. They could return this in new a :FULL-DOC property: * eldoc-display-in-echo-area would ignore it, since it is content that doesn't fit its target: * eldoc-display-in-buffer function would utilize to format a buffer that would look much like the *Help* buffer does nowadays. Whether that new property should be a string, a function, a buffer, or any of the above is an implementation detail we'd have to think up. Regardless, I'm sure something like this could be thought up for some future Python backend(s) as well: an Eldoc backend that returns a short summary (the signature, presumably) and a longer description of the thing at point. Other pieces of the puzzle to consider here are the somewhat underused/defunct help-at-pt.el which happens to have a good shortcut in 'C-h .'. It could be merged with ElDoc and lend that shortcut to M-x eldoc. Jo=C3=A3o