-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
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... |
This PR is stale because it has been open for 30 days with no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not convinced this is an awesome idea, but see my review comments anyway.
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! :) |
…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?
|
For the |
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? :) |
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. |
And you can blame me in a comment if you want! |
@ericvsmith this should be good for second review/merge now :) |
@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. |
@LewisGaul : Can you add support and tests for recursive dataclasses? See cpython/Lib/test/test_dataclasses.py Line 3296 in 3f3d82b
|
@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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last request for a cyclical test.
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 don't think the CI failures are related ( |
Thanks for making the requested changes! @ericvsmith: please review the changes made to this pull request. |
Thanks for taking the time to review @ericvsmith :) Is there anything else I need to do before this can be merged? |
@LewisGaul : No, nothing else. I'll try and finish up my final review and push of this tonight. Thanks for your patience. |
https://bugs.python.org/issue43080
See also: #14318