Skip to content

Commit

Permalink
Improve pathlib type annotations (#11646)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner authored Aug 26, 2023
1 parent bf339b1 commit c503c90
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sphinx/builders/html/_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sphinx.errors import ThemeError

if TYPE_CHECKING:
from sphinx.util._pathlib import _StrPath
from pathlib import Path


class _CascadingStyleSheet:
Expand Down Expand Up @@ -124,7 +124,7 @@ def __getitem__(self, key):
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:
Expand Down
6 changes: 3 additions & 3 deletions sphinx/environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

if TYPE_CHECKING:
from collections.abc import Generator, Iterator
from pathlib import Path

from docutils import nodes
from docutils.nodes import Node
Expand All @@ -34,7 +35,6 @@
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__)

Expand Down Expand Up @@ -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 = ''
Expand Down
7 changes: 3 additions & 4 deletions sphinx/testing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

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'


Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c503c90

Please sign in to comment.