Skip to content

Commit

Permalink
added first doc stub
Browse files Browse the repository at this point in the history
  • Loading branch information
srobuttiteraki committed Feb 19, 2019
1 parent 659aa48 commit 4533269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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__


Expand Down
9 changes: 9 additions & 0 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

0 comments on commit 4533269

Please sign in to comment.