bpo-32832: support override of ps1/ps2/output prefix for doctest parser#7141
bpo-32832: support override of ps1/ps2/output prefix for doctest parser#7141skirpichev wants to merge 1 commit into
Conversation
The Python stdlib allows override of sys.ps1/ps2 (to make IPython-like dynamic prompts and so on). In the IPython - customized parser class created to support doctests, written in such a style. This commit adds optional arguments for DocTestParser.__init__() to support same in the doctest module as well.
|
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). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. When your account is ready, please add a comment in this pull request Thanks again to your contribution and we look forward to looking at it! |
|
Github account name on b.p.o. was missed, added now. Sorry. |
|
@skirpichev bugs.python.org still says you have not signed the CLA. |
|
Sorry, probably forgot to confirm email last time. CLA was signed just now. BTW, it seems bugs.python.org was banned in Russia. |
|
@skirpichev , thank you for the pull request, but as @tim-one was -1 on this change in the discussion on the bug tracker, I'm going to close this. If Tim changes his decision in the future, please feel free to re-open this. Any additional discussion should happen on the bug tracker first before re-opening. Thanks! |
|
Thank you, but I'm not planning to contribute anymore in cpython, it's apparently worthless. |
|
@skirpichev, Python is a mature project now, with millions of users. The bar for making changes is correspondingly high. It can certainly still be done, but a strong case needs to be made. I left this on the bug tracker a year ago:
Since nothing more happened, there's still no real use case in sight, so I agree with @csabella closing this. |
IPython. That example was provided from the beginning. Maybe this patch doesn't remove all doctest customization, but noticeable part of (I think, the IPDocTestParser class entirely). |
|
But we discussed that on the bug tracker a year ago, and in the last message you left there, you agreed:
I left the bug open, on the chance that you would try to find an author of a widely used alternative shell who could say the patch would be a real help to them. But that's the last we heard. Your comments at the time suggested you thought IPython should be rewritten in other ways instead:
But that's not for you (or me) to decide - that's up to the IPython maintainers. Did you ask them? In the continued absence of at least one actual major potential user saying "yes, I want this!", there's really no case to be made for complicating long-stable code. It's nothing personal. It's about costs-vs-benefits guesses. |
Apparently, they think that fixing Python stdlib worthless as well. (The existence of IPython itself shows, that stdlib - sucks, CPython has no good built-in REPL capabilities.)
Given issues like https://bugs.python.org/issue26092, it seems I fail to have a mental model for stdlib maintenance. I will consider patching pytest's doctest plugin.
Sure, I didn't mean the opposite. |
|
So I take it a straight answer to my question is "no, I didn't ask". Then that remains a problem: you can't sell an idea as "a solution" if you can't find real users with problems it would actually solve. "I like it better this other way" just isn't enough. There's no point in repeating "worthless", unless you're just trying to blow off steam. It's pejorative and grossly overstated. About BPO 8408, I hadn't seen it before. The resolution doesn't surprise me, despite that it seemed unprincipled. What you may not know: Noam Yorav-Raphael contributed substantial features to IDLE, and eventually started his own Python shell project (DreamPie - between IDLE and IPython in power). Because he was well-known, and because his patch actually solved a real problem his users were actually having in DreamPie, Georg wasn't inclined to push back, so applied his patch. But I have no idea what "a right way" to solve that would have been. I wrote doctest 20 years ago, and never gave a thought to I hadn't seen your BPO 26092 before either, but don't know what you expected from it. Open source is driven by people scratching their own itches, and in that report you didn't identify a specific problem or a specific solution. Hoping other people will drop what they're doing to think about it doesn't usually work 😉. No problem in trying that, but the |
|
On Wed, May 15, 2019 at 10:06:53PM -0700, Tim Peters wrote:
you can't sell an idea as "a solution" if you
can't find real users with problems it would actually solve.
My projects are real (e.g. Diofant) and after that patch I may use
plain stdlib's doctest, not a forked one (e.g. from IPython).
I hadn't seen your BPO 26092 before either, but don't know what you
expected from it.
I expected that doctest will not touch displayhook at all (after all, CPython
allow custom displayhook, just like custom ps1/ps2). Now I forced
to revert reverted displayhook with pytest fixtures
(https://github.com/diofant/diofant/blob/bfd2d7d673968c604134c04cd5199b49c62c9810/conftest.py#L52-L53)
which looks awkward.
As I said, it's original issue seems to be wrong.
No problem in trying that, but the
python-ideas (or maybe python-dev if the idea is close to polished)
mailing list is far more suitable for such stuff than the issue tracker.
Or forking stdlib (e.g. with pytest) to workaround this problem as well.
Feel free to close BPO 26092, if you consider that issue as a feature.
Thank you for your time.
|
|
What's the relevance of Diofant? It appears to be a capable package for doing symbolic computation, but - unless it's very deeply buried in the docs - doesn't appear to make any attempt to supply its own shell. If not, I'm left clueless as to what actual problem you're trying to solve. I'll suggest a possibility: perhaps people writing doctests when using Diofant under IPython are frustrated that they "don't work" when they try to run them under plain-old-Python instead? That I'd have sympathy for. A good solution to that might be to merge IPython's doctest parsing into the core standard library. Best I can tell, there are only a handful of Python shells out there (Python, IDLE, IPython, DreamPie, bpython, ptpython), and they all (except IDLE) use either Python's or IPython's shell conventions. IPython's doctest parser handles both, so covers the universe of real-world possibilities. Then everything would "just work". |
|
On Thu, May 16, 2019 at 05:23:04PM -0700, Tim Peters wrote:
doesn't appear to make any attempt to supply its own shell.
I'm planning switch to the IPython's prompt conventions in docs as plain
CPython shell is not that actually people use for everyday work.
|
The Python stdlib allows override of sys.ps1/ps2 (to make IPython-like
dynamic prompts and so on). In the IPython - customized parser
class created to support doctests, written in such a style. This commit
adds optional arguments for DocTestParser.__init__() to support
same in the doctest module as well.
https://bugs.python.org/issue32832