MCPcopy
hub / github.com/python-attrs/attrs / _add_repr

Function _add_repr

src/attr/_make.py:1876–1888  ·  view source on GitHub ↗

Add a repr method to *cls*.

(cls, ns=None, attrs=None)

Source from the content-addressed store, hash-verified

1874
1875
1876def _add_repr(cls, ns=None, attrs=None):
1877 """
1878 Add a repr method to *cls*.
1879 """
1880 if attrs is None:
1881 attrs = cls.__attrs_attrs__
1882
1883 script, globs = _make_repr_script(attrs, ns)
1884 _compile_and_eval(
1885 script, globs, filename=_generate_unique_filename(cls, "__repr__")
1886 )
1887 cls.__repr__ = globs["__repr__"]
1888 return cls
1889
1890
1891def fields(cls):

Callers 2

test_underscoresMethod · 0.90
_make.pyFile · 0.85

Calls 3

_make_repr_scriptFunction · 0.85
_compile_and_evalFunction · 0.85

Tested by 1

test_underscoresMethod · 0.72