You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show only non-defaults when omit_defaults is set #309
Hi,
When omit_defaults=True is set, it works for the encoding however repr shows all the types. It would be good to show only non-default values in repr when this flag is set.
Can you say more about why you'd want that behavior? What's your use case?
I'm not sure coupling a simpler repr to omit_defaults makes sense (omit_defaults is about encoding, not repr-ing). I'd thought about omitting default values from the repr for all structs, but nixed it since neither dataclasses, attrs, nor pydantic do this.
Activity
jcrist commentedon Feb 10, 2023
Can you say more about why you'd want that behavior? What's your use case?
I'm not sure coupling a simpler repr to
omit_defaultsmakes sense (omit_defaultsis about encoding, not repr-ing). I'd thought about omitting default values from thereprfor all structs, but nixed it since neitherdataclasses,attrs, norpydanticdo this.rsmb7z commentedon Feb 10, 2023
Hi @jcrist
Yes I understand that
omit_defaultsis specific to encoding originally however having different flag will be okay too.Similar to performance improvment with
omit_defaultsduring encoding, I would prefer to view only arguments which are non-defaults. Expected behavior you will find here forContractclass.https://github.com/erdewit/ib_insync/blob/master/ib_insync/contract.py
jcrist commentedon Feb 16, 2023
I've added a new
repr_omit_defaultsoption in #322 that should do what you want.ml31415 commentedon Mar 30, 2024
This new option should probably be mentioned in the docs on the website as well.