bpo-43080: pprint for dataclass instances#24389
Conversation
|
I've realised this doesn't respect user-defined The best solution to this I can think of is to check EDIT: This solution doesn't work on master actually... |
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
ericvsmith
left a comment
There was a problem hiding this comment.
I'm still not convinced this is an awesome idea, but see my review comments anyway.
Sorry, something went wrong.
I'm happy to address the comments, but if we're not expecting it to be merged shall we just close the PR? I would like to see this feature make it into core, but I won't be offended if you're against it overall, and better not to waste time fixing stuff up if it's not going in anyway! :) |
Sorry, something went wrong.
…d repr is not currently respected
…o pprint-dataclasses
I've added a failing testcase to track this issue. @ericvsmith Do you have any thoughts on how best to tackle this? You suggested the following on the issue, is this approach worth pursuing here?
|
Sorry, something went wrong.
|
For the |
Sorry, something went wrong.
I see what you're suggesting when trying it out on 3.8, but it seems the qualname was 'fixed' in #22155, so this approach won't work on master. Any other ideas/preferences? :) |
Sorry, something went wrong.
You could do the same with Check that Again, it's super fragile, but since both modules are in the stdlib and will be tested to work together, I'm not so concerned. |
Sorry, something went wrong.
And you can blame me in a comment if you want! |
Sorry, something went wrong.
|
@ericvsmith this should be good for second review/merge now :) |
Sorry, something went wrong.
|
@LewisGaul : I'm planning on fixing a bug (which I can't find right now) dealing with repr of recursive dataclasses. I'm going to hold off on this until that one is merged, at which point we can do the same fix here. But if you haven't heard from me in a week or so, please ping me again. |
Sorry, something went wrong.
|
@LewisGaul : Can you add support and tests for recursive dataclasses? See cpython/Lib/test/test_dataclasses.py Line 3296 in 3f3d82b |
Sorry, something went wrong.
|
@ericvsmith I've added handling for recursive dataclasses. Note that this required some special-casing (to avoid backwards incompatibility of formatting other recursive objects), where the existing handling in the pprint module would have given the following: |
Sorry, something went wrong.
ericvsmith
left a comment
There was a problem hiding this comment.
One last request for a cyclical test.
Sorry, something went wrong.
|
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 |
Sorry, something went wrong.
|
I have made the requested changes; please review again. I don't think the CI failures are related ( |
Sorry, something went wrong.
|
Thanks for making the requested changes! @ericvsmith: please review the changes made to this pull request. |
Sorry, something went wrong.
|
Thanks for taking the time to review @ericvsmith :) Is there anything else I need to do before this can be merged? |
Sorry, something went wrong.
|
@LewisGaul : No, nothing else. I'll try and finish up my final review and push of this tonight. Thanks for your patience. |
Sorry, something went wrong.
https://bugs.python.org/issue43080
See also: #14318