-
-
Notifications
You must be signed in to change notification settings - Fork 385
support custom repr() callable for attributes #568
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
Conversation
not sure why the doctest fails. in an interactive shell it works: >>> import attr
>>> @attr.s
... class C(object):
... user = attr.ib()
... password = attr.ib(repr=lambda value: '***')
...
>>> C("me", "s3kr3t")
C(user='me', password=***) update: oops, seem i can't even copy/paste correctly... 🙈 |
The doctests says |
Cool. Other than #567 (comment), seems likely... Can review the patch more carefully in a bit. |
Cool! Left random comments just to help myself understand what this was doing mostly, but yeah looks like it'd indeed hit #212. |
Additionally to what Julian wrote, please add an example to |
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.
Almost there, but please also add an versionchanged
tag to attrib
, thanks!
sure, but what's the right value? |
Next release is 19.2.0. |
added in b1bd940 |
ok, please review again. i think i fully addressed all comments so far. |
pr description updated as well |
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.
Great, thanks everyone!
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.
Woohoo!
🚀 thanks all the quick turn-around |
This adds support for using a custom callable to be used instead of the default
repr()
when formatting individual attributes in the generated__repr()__
. Theattr.ib(repr=…)
argument now takes either abool
(as before), or a callable that takes a value and returns a string.Fixes #567. Fixes #212.