[issue36287] Make ast.dump() not output optional default fields

Batuhan Taskaya report at bugs.python.org
Mon Mar 16 06:00:56 EDT 2020


Batuhan Taskaya <batuhanosmantaskaya at gmail.com> added the comment:

@serhiy.storchaka, with these ASDL signatures, I have a patch that would omit default values for both Nones and [] in case they are redundant. But this is a bit different than your approach so I wanted to ask what's your opinion about adding an extra argument called omit_defaults, and only omit defaults it present. I'm adding this because unlike your first patch, these aren't actually defaults when creating the objects (like ast.Module(body=[x]) != ast.Module(body=[x], type_ignores=[])) so doing anything other than looking to that representation would be different than the actual result. What're your opinions about this? (I'm submitting the initial version of the patch before doing a PR)

----------
Added file: https://bugs.python.org/file48975/ast.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36287>
_______________________________________


More information about the Python-bugs-list mailing list