Skip to content

gh-112139: Add inspect.Signature.format and use it in pydoc #112143

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

Merged
merged 7 commits into from
Dec 2, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Nov 16, 2023

What do you think about __str__ with a parameter? Or should we add an alias for this, like def to_string(self, *, pretty)?

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks, it's great this is relatively simple to implement.

Should we make this a public, supported feature of inspect.signature? It may be useful for users other than pydoc. For example, we could add a __format__. Then perhaps something like f"{sig:78p}" could be used.

@sobolevn
Copy link
Member Author

Yes, I think we should add a new method called format to inspect.Signature and properly document it.

@sobolevn sobolevn changed the title gh-112139: Add pretty to inspect.Signature and use it in pydoc gh-112139: Add inspect.Signature.format and use it in pydoc Nov 18, 2023
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thank you! Sorry I forgot about reviewing this PR.

@JelleZijlstra JelleZijlstra merged commit a9574c6 into python:main Dec 2, 2023
@AlexWaygood
Copy link
Member

Wow, this is going to be a big quality-of-life improvement. Thanks @sobolevn and @JelleZijlstra! :D

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…python#112143)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…python#112143)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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.

3 participants