Description
@hynek thanks for the work on attrs
!
Ideally, I'd only like a field to appear in a class' repr if that field is set to a non-default value. An example of this approach is scikit-learn's approach to printing class representations.
I'm trying to understand if this is already possible currently in attrs
. I know that attrs
accepts a callable for the repr parameter of an attrs.field
. But reading through the documentation, it is not clear what context (if any) is available to the repr. If the class' default values and the actual value of the parameter are as context to the callable, it would be relatively straightforward to craft a returned string that accomplished this.
Can you provide some info on what's available to the callable so I can understand if this is possible?