chrisbouchard / easyrepr

Python decorator to automatically generate repr strings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow limiting __repr__ to declared attributes

chrisbouchard opened this issue · comments

Something like

>>> class UseEasyRepr:
...    foo: int
...    bar: str
...
...    @easyrepr(only_declared=True)
...    def __repr__(self):
...        ...
>>> x = UseEasyRepr()
>>> x.foo = 3
>>> x.bar = 'hello world'
>>> x.baz = 42
>>> x.blah = object()
>>> repr(x)
"UseEasyRepr(foo=3, bar='hello world')"

We'd probably want to ignore declared attributes that are not actually defined.