diff options
author | Kirill Podoprigora <kirill.bast9@mail.ru> | 2024-02-17 15:39:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-17 15:39:48 (GMT) |
commit | ee3d8dcb005cd4e7ed92403dc07723f98573ae05 (patch) | |
tree | 0167bb66b11dd4144714aa5c81c14d8c51ee07c4 /Lib/pydoc.py | |
parent | a23aecc73777e6370792728c4dcd3af8999ba791 (diff) | |
download | cpython-ee3d8dcb005cd4e7ed92403dc07723f98573ae05.zip cpython-ee3d8dcb005cd4e7ed92403dc07723f98573ae05.tar.gz cpython-ee3d8dcb005cd4e7ed92403dc07723f98573ae05.tar.bz2 |
[3.11] gh-107155: Fix help() for lambda function with return annotation (GH-115613)
(cherry picked from commit b9a9e3dd62326b726ad2e8e8efd87ca6327b4019)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index c983cbb..56a47dc 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1128,7 +1128,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 = '(...)' @@ -1581,7 +1582,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] # remove parentheses if not argspec: argspec = '(...)' decl = asyncqualifier + title + argspec + note |