2828
2929# stdlib
3030import builtins
31+ from contextlib import suppress
3132from inspect import cleandoc
3233from types import MethodType
3334from typing import Any , Callable , Dict , Optional , Sequence , Type , TypeVar , Union
3435
3536# this package
36- from domdf_python_tools .compat import PYPY
37+ from domdf_python_tools .compat import PYPY , PYPY37
3738from domdf_python_tools .typing import MethodDescriptorType , MethodWrapperType , WrapperDescriptorType
3839
3940__all__ = [
@@ -335,6 +336,13 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
335336 continue
336337 elif PYPY and isinstance (attribute , MethodType ):
337338 continue # pragma: no cover (!PyPy)
339+ elif PYPY37 :
340+ if attribute is getattr (object , attr_name , None ):
341+ continue
342+ elif attribute is getattr (float , attr_name , None ):
343+ continue
344+ elif attribute is getattr (str , attr_name , None ):
345+ continue
338346
339347 if attribute is None :
340348 continue
@@ -345,7 +353,8 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
345353
346354 doc : Optional [str ] = attribute .__doc__
347355 if doc in {None , base_docstring }:
348- attribute .__doc__ = new_docstrings [attr_name ]
356+ with suppress (AttributeError , TypeError ):
357+ attribute .__doc__ = new_docstrings [attr_name ]
349358
350359
351360def prettify_docstrings (obj : Type ) -> Type :
@@ -372,10 +381,8 @@ def prettify_docstrings(obj: Type) -> Type:
372381 if "return" not in annotations or annotations ["return" ] is Any :
373382 annotations ["return" ] = new_return_types [attribute ]
374383
375- try :
384+ with suppress ( AttributeError , TypeError ) :
376385 getattr (obj , attribute ).__annotations__ = annotations
377- except AttributeError : # pragma: no cover
378- pass
379386
380387 if issubclass (obj , tuple ) and obj .__repr__ .__doc__ == "Return a nicely formatted representation string" :
381388 obj .__repr__ .__doc__ = repr_docstring
0 commit comments