From b4bb645a8565410b48f10ffb0c2d9c8b49a2e18a Mon Sep 17 00:00:00 2001 From: Bryann Valderrama Date: Mon, 17 Feb 2025 08:50:46 -0500 Subject: [PATCH] chore: simplify code and add inline comment --- docs/conf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index dd19bc0..ef71801 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -181,14 +181,16 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None: while hasattr(obj, "__wrapped__"): obj = obj.__wrapped__ + # Get the file path where the object is defined try: + # Try to get the file path of the object directly file_path = inspect.getsourcefile(obj) except Exception: - file_path = None - if not file_path: try: + # If that fails, try to get the file path of the module where the object is defined file_path = inspect.getsourcefile(sys.modules[obj.__module__]) except Exception: + # If both attempts fail, set file_path to None file_path = None if not file_path: return None