Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilo59 committed Nov 7, 2023
1 parent 465375f commit dfcb42b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions docs/checks/docs_link_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ def check_file(self, file: pathlib.Path) -> List[LinkReport]:
@click.option(
"--path",
"-p",
type=click.Path(exists=True, file_okay=True),
type=click.Path(exists=True, file_okay=True, path_type=pathlib.Path),
default=".",
help="Path to markdown file(s) to check",
)
@click.option(
"--docs-root",
"-r",
type=click.Path(exists=True, file_okay=False),
type=click.Path(exists=True, file_okay=False, path_type=pathlib.Path),
default=None,
help="Root to all docs for link checking",
)
Expand All @@ -340,27 +340,30 @@ def check_file(self, file: pathlib.Path) -> List[LinkReport]:
)
@click.option("--skip-external", is_flag=True)
def scan_docs_click(
path: str, docs_root: Optional[str], site_prefix: str, skip_external: bool
path: pathlib.Path,
docs_root: Optional[pathlib.Path],
site_prefix: str,
skip_external: bool,
) -> None:
code, message = scan_docs(path, docs_root, site_prefix, skip_external)
click.echo(message)
sys.exit(code)


def scan_docs(
path: str | pathlib.Path, docs_root: str | pathlib.Path | None, site_prefix: str, skip_external: bool
path: pathlib.Path,
docs_root: pathlib.Path | None,
site_prefix: str,
skip_external: bool,
) -> tuple[int, str]:
path = pathlib.Path(path)
if docs_root:
docs_root = pathlib.Path(docs_root)
else:
if not docs_root:
docs_root = path

if not docs_root.is_dir():
return 1, f"Docs root path: {docs_root} is not a directory"

# prepare our return value
result: List[LinkReport] = list()
result: List[LinkReport] = []
checker = LinkChecker(path, docs_root, site_prefix, skip_external)

if path.is_dir():
Expand Down

0 comments on commit dfcb42b

Please sign in to comment.