Improve lookup in `Project.path2doc()`

This commit is contained in:
Adam Turner committed 2024-11-04 18:03:26 +00:00
1 parent 2ccbc3209a
commit 6f0c8f75ac
1 file changed
+2 -2
+2 -2
View File
@@ -96,10 +96,10 @@ class Project:
*filename* should be absolute or relative to the source directory.
"""
path = Path(filename)
try:
return self._path_to_docname[filename] # type: ignore[index]
return self._path_to_docname[path]
except KeyError:
path = Path(filename)
if path.is_absolute():
with contextlib.suppress(ValueError):
path = path.relative_to(self.srcdir)