Skip to content

Commit c503c90

Browse files
authored
Improve pathlib type annotations (#11646)
1 parent bf339b1 commit c503c90

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

sphinx/builders/html/_assets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sphinx.errors import ThemeError
1010

1111
if TYPE_CHECKING:
12-
from sphinx.util._pathlib import _StrPath
12+
from pathlib import Path
1313

1414

1515
class _CascadingStyleSheet:
@@ -124,7 +124,7 @@ def __getitem__(self, key):
124124
return os.fspath(self.filename)[key]
125125

126126

127-
def _file_checksum(outdir: _StrPath, filename: str | os.PathLike[str]) -> str:
127+
def _file_checksum(outdir: Path, filename: str | os.PathLike[str]) -> str:
128128
filename = os.fspath(filename)
129129
# Don't generate checksums for HTTP URIs
130130
if '://' in filename:

sphinx/environment/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
if TYPE_CHECKING:
2626
from collections.abc import Generator, Iterator
27+
from pathlib import Path
2728

2829
from docutils import nodes
2930
from docutils.nodes import Node
@@ -34,7 +35,6 @@
3435
from sphinx.domains import Domain
3536
from sphinx.events import EventManager
3637
from sphinx.project import Project
37-
from sphinx.util._pathlib import _StrPath
3838

3939
logger = logging.getLogger(__name__)
4040

@@ -148,8 +148,8 @@ class BuildEnvironment:
148148

149149
def __init__(self, app: Sphinx):
150150
self.app: Sphinx = app
151-
self.doctreedir: _StrPath = app.doctreedir
152-
self.srcdir: _StrPath = app.srcdir
151+
self.doctreedir: Path = app.doctreedir
152+
self.srcdir: Path = app.srcdir
153153
self.config: Config = None # type: ignore[assignment]
154154
self.config_status: int = CONFIG_UNSET
155155
self.config_status_extra: str = ''

sphinx/testing/util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
if TYPE_CHECKING:
1919
from io import StringIO
20+
from pathlib import Path
2021

2122
from docutils.nodes import Node
2223

23-
from sphinx.util._pathlib import _StrPath
24-
2524
__all__ = 'SphinxTestApp', 'SphinxTestAppWrapperForSkipBuilding'
2625

2726

@@ -82,8 +81,8 @@ class SphinxTestApp(application.Sphinx):
8281
def __init__(
8382
self,
8483
buildername: str = 'html',
85-
srcdir: _StrPath | None = None,
86-
builddir: _StrPath | None = None,
84+
srcdir: Path | None = None,
85+
builddir: Path | None = None,
8786
freshenv: bool = False,
8887
confoverrides: dict | None = None,
8988
status: IO | None = None,

0 commit comments

Comments
 (0)