summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorKirill Podoprigora <kirill.bast9@mail.ru>2024-02-17 12:47:51 (GMT)
committerGitHub <noreply@github.com>2024-02-17 12:47:51 (GMT)
commitb9a9e3dd62326b726ad2e8e8efd87ca6327b4019 (patch)
tree58a4285bc5da3660c464cdee21526308bd52ddcb /Lib/pydoc.py
parent664965a1c141e8af5eb465d29099781a6a2fc3f3 (diff)
downloadcpython-b9a9e3dd62326b726ad2e8e8efd87ca6327b4019.zip
cpython-b9a9e3dd62326b726ad2e8e8efd87ca6327b4019.tar.gz
cpython-b9a9e3dd62326b726ad2e8e8efd87ca6327b4019.tar.bz2
gh-107155: Fix help() for lambda function with return annotation (GH-107401)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 6d145ab..9bb64fe 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1144,7 +1144,8 @@ class HTMLDoc(Doc):
# XXX lambda's won't usually have func_annotations['return']
# since the syntax doesn't support but it is possible.
# So removing parentheses isn't truly safe.
- argspec = argspec[1:-1] # remove parentheses
+ if not object.__annotations__:
+ argspec = argspec[1:-1] # remove parentheses
if not argspec:
argspec = '(...)'
@@ -1586,7 +1587,8 @@ location listed above.
# XXX lambda's won't usually have func_annotations['return']
# since the syntax doesn't support but it is possible.
# So removing parentheses isn't truly safe.
- argspec = argspec[1:-1] # remove parentheses
+ if not object.__annotations__:
+ argspec = argspec[1:-1]
if not argspec:
argspec = '(...)'
decl = asyncqualifier + title + argspec + note