mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve `pathlib
` type annotations (#11646)
This commit is contained in:
parent
bf339b123e
commit
c503c90090
@ -9,7 +9,7 @@ from sphinx.deprecation import RemovedInSphinx90Warning
|
||||
from sphinx.errors import ThemeError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class _CascadingStyleSheet:
|
||||
@ -124,7 +124,7 @@ class _JavaScript:
|
||||
return os.fspath(self.filename)[key]
|
||||
|
||||
|
||||
def _file_checksum(outdir: _StrPath, filename: str | os.PathLike[str]) -> str:
|
||||
def _file_checksum(outdir: Path, filename: str | os.PathLike[str]) -> str:
|
||||
filename = os.fspath(filename)
|
||||
# Don't generate checksums for HTTP URIs
|
||||
if '://' in filename:
|
||||
|
@ -24,6 +24,7 @@ from sphinx.util.osutil import canon_path, os_path
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Generator, Iterator
|
||||
from pathlib import Path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.nodes import Node
|
||||
@ -34,7 +35,6 @@ if TYPE_CHECKING:
|
||||
from sphinx.domains import Domain
|
||||
from sphinx.events import EventManager
|
||||
from sphinx.project import Project
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -148,8 +148,8 @@ class BuildEnvironment:
|
||||
|
||||
def __init__(self, app: Sphinx):
|
||||
self.app: Sphinx = app
|
||||
self.doctreedir: _StrPath = app.doctreedir
|
||||
self.srcdir: _StrPath = app.srcdir
|
||||
self.doctreedir: Path = app.doctreedir
|
||||
self.srcdir: Path = app.srcdir
|
||||
self.config: Config = None # type: ignore[assignment]
|
||||
self.config_status: int = CONFIG_UNSET
|
||||
self.config_status_extra: str = ''
|
||||
|
@ -17,11 +17,10 @@ from sphinx.pycode import ModuleAnalyzer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
|
||||
from docutils.nodes import Node
|
||||
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
|
||||
__all__ = 'SphinxTestApp', 'SphinxTestAppWrapperForSkipBuilding'
|
||||
|
||||
|
||||
@ -82,8 +81,8 @@ class SphinxTestApp(application.Sphinx):
|
||||
def __init__(
|
||||
self,
|
||||
buildername: str = 'html',
|
||||
srcdir: _StrPath | None = None,
|
||||
builddir: _StrPath | None = None,
|
||||
srcdir: Path | None = None,
|
||||
builddir: Path | None = None,
|
||||
freshenv: bool = False,
|
||||
confoverrides: dict | None = None,
|
||||
status: IO | None = None,
|
||||
|
Loading…
Reference in New Issue
Block a user