Skip to content

Commit 6110fe1

Browse files
committed
prettify_docstring: Don't try and set docstring of getattr returns None (usually for properties / attributes).
1 parent 3983f37 commit 6110fe1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

domdf_python_tools/doctools.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,9 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
325325
if hasattr(base, attr_name):
326326
base_docstring = getattr(base, attr_name).__doc__
327327

328-
doc: Optional[str] = getattr(obj, attr_name).__doc__
329-
330-
if doc in {None, base_docstring}:
331-
getattr(obj, attr_name).__doc__ = new_docstrings[attr_name]
328+
doc: Optional[str] = attribute.__doc__
329+
if doc in {None, base_docstring} and attribute is not None:
330+
attribute.__doc__ = new_docstrings[attr_name]
332331

333332

334333
def prettify_docstrings(obj: Type) -> Type:

0 commit comments

Comments
 (0)