From 3bf1cd8efa72709fa0d5b41c57c7303181d27668 Mon Sep 17 00:00:00 2001 From: "G.Pruvost" Date: Sat, 22 Jun 2024 02:11:51 +0200 Subject: [PATCH] BUG: Fix a fatal error preventing documentation generation in some cases (#302) * Update __init__.py Got a fatal exception on this line, which prevented the generation of the documentation. The problem is that some variable is initialized in a try bloc but still used out of it afterwards. If the getattr fails line 682 - which was my problem - then the variable is used without being initialized, which lead to fatal error. * Use `try-else` block --- pdoc/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdoc/__init__.py b/pdoc/__init__.py index 3ceb3ee1..a592def5 100644 --- a/pdoc/__init__.py +++ b/pdoc/__init__.py @@ -686,9 +686,10 @@ def __init__(self, module: Union[ModuleType, str], *, except AttributeError: warn(f"Module {self.module!r} doesn't contain identifier `{name}` " "exported in `__all__`") - if not _is_blacklisted(name, self): - obj = inspect.unwrap(obj) - public_objs.append((name, obj)) + else: + if not _is_blacklisted(name, self): + obj = inspect.unwrap(obj) + public_objs.append((name, obj)) else: def is_from_this_module(obj): mod = inspect.getmodule(inspect.unwrap(obj))