From e2132859879f25f79ece247908a63b267e5baa6c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 13 Sep 2024 23:17:09 +0200 Subject: [PATCH] mypy/fs,sphinx --- rwx/fs/__init__.py | 4 ++-- rwx/prj/sphinx.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rwx/fs/__init__.py b/rwx/fs/__init__.py index a8865e7..d1c2732 100644 --- a/rwx/fs/__init__.py +++ b/rwx/fs/__init__.py @@ -68,12 +68,12 @@ def read_file_text(file_path: str, charset: str = CHARSET) -> str: return read_file_bytes(file_path).decode(charset) -def wipe(path: str) -> None: +def wipe(path: Path) -> None: """Wipe provided path, whether directory or file.""" try: shutil.rmtree(path) except NotADirectoryError: - Path(path).unlink(missing_ok=True) + path.unlink(missing_ok=True) except FileNotFoundError: pass diff --git a/rwx/prj/sphinx.py b/rwx/prj/sphinx.py index b85cfa5..be207ef 100644 --- a/rwx/prj/sphinx.py +++ b/rwx/prj/sphinx.py @@ -1,5 +1,10 @@ """Project consisting only of a Sphinx documentation.""" +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path + from sphinx.cmd.build import build_main from rwx.fs import wipe @@ -15,7 +20,7 @@ class SphinxProject(Project): def build(self) -> None: """Build the project.""" - output_root: str = self.root / "out" + output_root: Path = self.root / "out" wipe(output_root) arguments: list[str] = [ "-E", @@ -30,9 +35,9 @@ class SphinxProject(Project): "-D", "html_theme={}".format("sphinx_rtd_theme"), "-c", - self.root, + str(self.root), # "-C", - self.root / self.name, - output_root / "web", + str(self.root / self.name), + str(output_root / "web"), ] build_main(arguments)