worked out the rest of the pyright errors
This commit is contained in:
parent
ba28ea0abf
commit
e79a8b9b87
|
@ -27,6 +27,18 @@ class SourceNode:
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"SourceNode({self._path}, {self._is_dir}) [is_md={self._is_md}]"
|
return f"SourceNode({self._path}, {self._is_dir}) [is_md={self._is_md}]"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_dir(self) -> bool:
|
||||||
|
return self._is_dir
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_md(self) -> bool:
|
||||||
|
return self._is_md
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self) -> Path:
|
||||||
|
return self._path
|
||||||
|
|
||||||
def link_target(self, prefix: str = "/") -> str:
|
def link_target(self, prefix: str = "/") -> str:
|
||||||
xpath = self._path.with_suffix('.html') if self._is_md else self._path
|
xpath = self._path.with_suffix('.html') if self._is_md else self._path
|
||||||
return urlquote(prefix + xpath.as_posix())
|
return urlquote(prefix + xpath.as_posix())
|
||||||
|
@ -74,25 +86,24 @@ class SourceIndex:
|
||||||
self._byname: dict[str, SourceNode] = {}
|
self._byname: dict[str, SourceNode] = {}
|
||||||
self._byalias: dict[str, SourceNode] = {}
|
self._byalias: dict[str, SourceNode] = {}
|
||||||
for node in nodelist:
|
for node in nodelist:
|
||||||
if node._is_dir:
|
if node.is_dir:
|
||||||
continue
|
continue
|
||||||
if node._is_md:
|
if node.is_md:
|
||||||
tmp = node._path.with_suffix('')
|
tmp = node.path.with_suffix('')
|
||||||
key = tmp.name
|
key = tmp.name
|
||||||
if key not in self._byname:
|
if key not in self._byname:
|
||||||
self._byname[key] = node
|
self._byname[key] = node
|
||||||
self._byname[tmp.as_posix()] = node
|
self._byname[tmp.as_posix()] = node
|
||||||
if node.metadata:
|
if node.metadata:
|
||||||
aliases = node.metadata.get('aliases', [])
|
aliases: list[str] = node.metadata.get('aliases', [])
|
||||||
if isinstance(aliases, list):
|
for alias in aliases:
|
||||||
for alias in aliases:
|
if alias not in self._byalias:
|
||||||
if alias not in self._byalias:
|
self._byalias[alias] = node
|
||||||
self._byalias[alias] = node
|
|
||||||
else:
|
else:
|
||||||
key = node._path.name
|
key = node.path.name
|
||||||
if key not in self._byname:
|
if key not in self._byname:
|
||||||
self._byname[key] = node
|
self._byname[key] = node
|
||||||
self._byname[node._path.as_posix()] = node
|
self._byname[node.path.as_posix()] = node
|
||||||
|
|
||||||
def lookup(self, reference: str) -> tuple[SourceNode | None, str | None]:
|
def lookup(self, reference: str) -> tuple[SourceNode | None, str | None]:
|
||||||
if reference in self._byname:
|
if reference in self._byname:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user