Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pathlib type annotations #11646

Merged
merged 1 commit into from Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions sphinx/builders/html/_assets.py
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
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
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