Skip to content

Commit

Permalink
chore: simplify code and add inline comment
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed Feb 17, 2025
1 parent 95632df commit a23a451
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,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
Expand Down

0 comments on commit a23a451

Please sign in to comment.