Fix crash (only convert __file__ attribute to a Path if it is not None)

This commit is contained in:
Maximilian Albert
2025-01-19 23:27:37 +00:00
parent 0ad565b95b
commit 383c596975

View File

@@ -183,10 +183,12 @@ class DirectObjectAccess:
def py__file__(self) -> Optional[Path]:
try:
return Path(self._obj.__file__)
__file__attribute = self._obj.__file__
except AttributeError:
return None
return Path(__file__attribute) if __file__attribute is not None else None
def py__doc__(self):
return inspect.getdoc(self._obj) or ''