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-112139: Add inspect.Signature.format and use it in pydoc #112143

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.

Lib/inspect.py Outdated Show resolved Hide resolved
Lib/inspect.py Outdated Show resolved Hide resolved
Lib/test/test_pydoc.py Outdated Show resolved Hide resolved
@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.

Doc/library/inspect.rst Outdated Show resolved Hide resolved
Lib/test/test_inspect/test_inspect.py Show resolved Hide resolved
@JelleZijlstra JelleZijlstra merged commit a9574c6 into python:main Dec 2, 2023
31 checks passed
@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>
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.

None yet

3 participants