From 4533269ee818da1451e2b37641f7ac6f97bfd537 Mon Sep 17 00:00:00 2001 From: Simone Robutti Date: Fri, 15 Feb 2019 19:02:08 +0100 Subject: [PATCH] added first doc stub --- src/attr/_make.py | 8 ++++++++ tests/test_make.py | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/attr/_make.py b/src/attr/_make.py index 843c76bd7..d182e9898 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -720,6 +720,13 @@ def _add_method_dunders(self, method): except AttributeError: pass + try: + method.__doc__ = "Method generated by attrs for {}".format( + self._cls.__qualname__ + ) + except AttributeError: + pass + return method @@ -1273,6 +1280,7 @@ def _make_init(attrs, post_init, frozen, slots, cache_hash, base_attr_map): __init__ = locs["__init__"] __init__.__annotations__ = annotations + return __init__ diff --git a/tests/test_make.py b/tests/test_make.py index d02c12420..e46848821 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -1587,3 +1587,12 @@ class B(A): "Comparision of subclasses using %s is deprecated and will be " "removed in 2019." % (op,) ) == w.message.args[0] + + +class TestDocs: + def test_init_docs(self): + @attr.s + class A: + pass + + assert A.__qualname__ in A.__init__.__doc__