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
def__repr__(self) ->str:
"""Exclude fields with values equal to the field default."""kv_pairs= (f"{f.name}={getattr(self, f.name)!r}"forfinfields(self) ifgetattr(self, f.name) !=f.default)
returnf"{self.__class__.__name__}({', '.join(kv_pairs)})"
Summary
We have some dataclasses with a lot of fields, and the reprs can be a bit overwhelming, especially when included in logs/warnings/exceptions.
Request is for reprs to exclude fields where their value is
==
the field default.KwargDefinition
(and subtypes) and the OpenAPI spec models are examples of types that would benefit from this.Basic Example
vs
Drawbacks and Impact
Pros: easier to parse and reason about.
Cons: maybe some users prefer the verbosity.
Unresolved questions
Could changing the reprs of these things be considered breaking??
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: