Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-107155: Fix help(lambda_func) when lambda_func has `__annotati… #107401

Merged
merged 12 commits into from
Feb 17, 2024

Conversation

Eclips4
Copy link
Member

@Eclips4 Eclips4 commented Jul 28, 2023

...ons__`

I cannot find any example with parenthesis in signature of lambda 😄 .

Lib/pydoc.py Outdated Show resolved Hide resolved
@Eclips4
Copy link
Member Author

Eclips4 commented Jul 31, 2023

Thanks for your help @AA-Turner !

Is there anything else that needs to be done? Also, I think this kind of PR doesn't need a NEWS entry.

@AlexWaygood
Copy link
Member

Also, I think this kind of PR doesn't need a NEWS entry.

Here's how to think about whether a bugfix PR deserves a news entry: does the PR fix a bug that users have noticed? If so, users deserve to know about it being fixed, so it should have a news entry. If not, the PR should be closed, as users won't notice the change being made, which makes the PR have very limited value.

In this case, a user reported the bug on the GitHub issue tracker, so at least one user will notice the change. As such, it definitely deserves a news entry :)

@AA-Turner
Copy link
Member

I'd agree with Alex, this is visible to end-users (although very rare!). Something that outlines that help and pydoc now correctly display lambdas with return annotations would be enough.

A

@Eclips4
Copy link
Member Author

Eclips4 commented Aug 1, 2023

After your words, I agree that this PR needs a NEWS entry, thanks for thoroughly explanation!

I wrote some lines, please, check it.

…j1K9L.rst

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

A

@Eclips4
Copy link
Member Author

Eclips4 commented Jan 1, 2024

Now I'm have resolved the merge conflict.

Lib/pydoc.py Outdated Show resolved Hide resolved
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like modification of the original object. It is not thread-safe. It does not work if __annotations__ is read-only. It does not restore {'return': None}.

Maybe just keep the parentheses if the lambda object has annotations? In any case this is not a valid Python syntax.

Lib/pydoc.py Show resolved Hide resolved
@Eclips4
Copy link
Member Author

Eclips4 commented Feb 17, 2024

I do not like modification of the original object. It is not thread-safe. It does not work if __annotations__ is read-only. It does not restore {'return': None}.

Maybe just keep the parentheses if the lambda object has annotations? In any case this is not a valid Python syntax.

All of your points makes sense to me, thanks for them! I've made changes, please take a look at them :)
Altough, there's one question: now for lambdas without any params but with __annotations__ = {"return": int} help looks like that:

Help on function <lambda> in module __main__:

<lambda> lambda () -> int

Is it okay or we should change it?

@serhiy-storchaka
Copy link
Member

lambda with annotations can't be expressed in Python syntax anyway. At least it now has balanced parentheses and does not truncate words.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) February 17, 2024 12:46
@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Feb 17, 2024
@serhiy-storchaka serhiy-storchaka merged commit b9a9e3d into python:main Feb 17, 2024
36 checks passed
@miss-islington-app
Copy link

Thanks @Eclips4 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @Eclips4 and @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b9a9e3dd62326b726ad2e8e8efd87ca6327b4019 3.12

@miss-islington-app
Copy link

Sorry, @Eclips4 and @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker b9a9e3dd62326b726ad2e8e8efd87ca6327b4019 3.11

@bedevere-app
Copy link

bedevere-app bot commented Feb 17, 2024

GH-115612 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Feb 17, 2024
Eclips4 added a commit to Eclips4/cpython that referenced this pull request Feb 17, 2024
…notation (pythonGH-107401)

(cherry picked from commit b9a9e3d)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
@bedevere-app
Copy link

bedevere-app bot commented Feb 17, 2024

GH-115613 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 17, 2024
@Eclips4 Eclips4 deleted the issue-107155 branch February 17, 2024 14:36
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants