Skip to content

bpo-37755: Use configured output in pydoc instead of pager #15105

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 4 commits into from
Jun 8, 2024

Conversation

eht16
Copy link
Contributor

@eht16 eht16 commented Aug 4, 2019

If the Helper() class was initialized with an output, the topics, keywords and symbols help still use the pager instead of the output.
Change the behavior so the output is used if available while keeping the previous behavior if no output was configured.

https://bugs.python.org/issue37755

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

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.

Please add tests and a NEWS entry.

@bedevere-app
Copy link

bedevere-app bot commented Feb 29, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@eht16 eht16 force-pushed the issue37755_pydoc_pager branch from 0bb4ee6 to 910baae Compare June 2, 2024 11:29
@bedevere-app
Copy link

bedevere-app bot commented Jun 2, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@eht16 eht16 force-pushed the issue37755_pydoc_pager branch from 910baae to c1254ea Compare June 2, 2024 11:43
If the Helper() class was initialized with an output, the topics, keywords and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the previous behavior if no output was configured.
@eht16 eht16 force-pushed the issue37755_pydoc_pager branch from c1254ea to 207a962 Compare June 2, 2024 11:48
@eht16
Copy link
Contributor Author

eht16 commented Jun 2, 2024

I have made the requested changes; please review again

Though I'm not sure why the Docs action fail, I don't see how the references are incorrect.

@bedevere-app
Copy link

bedevere-app bot commented Jun 2, 2024

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from serhiy-storchaka June 2, 2024 12:13
Comment on lines 719 to 720
pydoc.getpager = getpager_new
try:
Copy link
Member

Choose a reason for hiding this comment

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

You can use test.support.swap_attr() or unittest.mock.patch().

It would be nice to test also that the pager was not called (otherwise why do you need to patch it?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

I modified also the existing test test_help_output_redirect from which I borrowed the "getpager" handling code. To me it also seems more reasonable to use mocking here.

eht16 and others added 2 commits June 2, 2024 18:24
…1936.ETeW9x.rst

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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.

Very good. But it seems that getpager() is never called in pydoc, so mocking it does not have effect. Should not you mock pager?

@eht16
Copy link
Contributor Author

eht16 commented Jun 8, 2024

Very good. But it seems that getpager() is never called in pydoc, so mocking it does not have effect. Should not you mock pager?

Oops, thanks for noticing. I thought getpager() get called indirectly via pager() but anyway, it is better to mock the pager() function directly.

I'd like to squash the "fixup" commits or do you want to it yourself on merging?

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.

LGTM.

Usually we only squash on merging.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Jun 8, 2024
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) June 8, 2024 09:14
@serhiy-storchaka serhiy-storchaka merged commit 2080425 into python:main Jun 8, 2024
36 of 37 checks passed
@miss-islington-app
Copy link

Thanks @eht16 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 8, 2024
…15105)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
(cherry picked from commit 2080425)

Co-authored-by: Enrico Tröger <enrico.troeger@uvena.de>
@miss-islington-app
Copy link

Sorry, @eht16 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 2080425154d235b4b7dcc9a8a2f58e71769125ca 3.12

@bedevere-app
Copy link

bedevere-app bot commented Jun 8, 2024

GH-120261 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 8, 2024
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Jun 8, 2024
…thonGH-15105)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
(cherry picked from commit 2080425)

Co-authored-by: Enrico Tröger <enrico.troeger@uvena.de>
@bedevere-app
Copy link

bedevere-app bot commented Jun 8, 2024

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jun 8, 2024
@eht16 eht16 deleted the issue37755_pydoc_pager branch June 8, 2024 09:41
serhiy-storchaka added a commit that referenced this pull request Jun 8, 2024
…-15105) (GH-120262)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
(cherry picked from commit 2080425)

Co-authored-by: Enrico Tröger <enrico.troeger@uvena.de>
serhiy-storchaka pushed a commit that referenced this pull request Jun 8, 2024
…-15105) (GH-120261)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
(cherry picked from commit 2080425)

Co-authored-by: Enrico Tröger <enrico.troeger@uvena.de>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
…15105)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
…15105)

If the Helper() class was initialized with an output, the topics, keywords
and symbols help still use the pager instead of the output.
Change the behavior so  the output is used if available while keeping the
previous behavior if no output was configured.
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