From d44d4f83ad9810ba6f44fe0739d8175fb44c1258 Mon Sep 17 00:00:00 2001 From: Bryant Finney Date: Wed, 23 Oct 2024 19:42:04 -0400 Subject: [PATCH] fix(#753): API documentation for `unittest.mock` (#754) * fix(mitmproxy/pdoc#753): add failing test Signed-off-by: Bryant Finney * fix(mitmproxy/pdoc#753): avoid `TypeError`s ... by checking for the `__contains__` attribute Signed-off-by: Bryant Finney * fix(mitmproxy/pdoc#753): Apply suggestion ... from @mhils during mitmproxy/pdoc#754 Signed-off-by: Bryant Finney --------- Signed-off-by: Bryant Finney --- pdoc/doc.py | 2 +- test/test_smoke.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pdoc/doc.py b/pdoc/doc.py index 51468dd2..752cd178 100644 --- a/pdoc/doc.py +++ b/pdoc/doc.py @@ -445,7 +445,7 @@ def _taken_from(self, member_name: str, obj: Any) -> tuple[str, str]: mod = _safe_getattr(obj, "__module__", None) qual = _safe_getattr(obj, "__qualname__", None) - if mod and qual and "" not in qual: + if mod and isinstance(qual, str) and "" not in qual: return mod, qual else: # This might be wrong, but it's the best guess we have. diff --git a/test/test_smoke.py b/test/test_smoke.py index 60f10417..f8c67c49 100644 --- a/test/test_smoke.py +++ b/test/test_smoke.py @@ -12,7 +12,7 @@ m.name for m in pkgutil.iter_modules() if not m.name.startswith("_") and m.name not in ("test", "idlelib", "py") -] +] + ["unittest.mock"] @pytest.mark.slow