Skip to content

Commit 2ccbc32

Browse files
committed
Use type hints for directories
1 parent 1266c42 commit 2ccbc32

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

sphinx/builders/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from sphinx.application import Sphinx
4949
from sphinx.config import Config
5050
from sphinx.events import EventManager
51+
from sphinx.util._pathlib import _StrPath
5152
from sphinx.util.tags import Tags
5253

5354

@@ -94,10 +95,10 @@ class Builder:
9495
supported_data_uri_images: bool = False
9596

9697
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
97-
self.srcdir = app.srcdir
98-
self.confdir = app.confdir
99-
self.outdir = app.outdir
100-
self.doctreedir = app.doctreedir
98+
self.srcdir: _StrPath = app.srcdir
99+
self.confdir: _StrPath = app.confdir
100+
self.outdir: _StrPath = app.outdir
101+
self.doctreedir: _StrPath = app.doctreedir
101102
ensuredir(self.doctreedir)
102103

103104
self.app: Sphinx = app

sphinx/environment/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
if TYPE_CHECKING:
3434
from collections.abc import Callable, Iterable, Iterator
35-
from pathlib import Path
3635
from typing import Any, Literal
3736

3837
from docutils import nodes
@@ -102,8 +101,8 @@ class BuildEnvironment:
102101

103102
def __init__(self, app: Sphinx) -> None:
104103
self.app: Sphinx = app
105-
self.doctreedir: Path = app.doctreedir
106-
self.srcdir: Path = app.srcdir
104+
self.doctreedir: _StrPath = app.doctreedir
105+
self.srcdir: _StrPath = app.srcdir
107106
self.config: Config = None # type: ignore[assignment]
108107
self.config_status: int = CONFIG_UNSET
109108
self.config_status_extra: str = ''

sphinx/writers/html5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def visit_image(self, node: Element) -> None:
752752
# but it tries the final file name, which does not necessarily exist
753753
# yet at the time the HTML file is written.
754754
if not ('width' in node and 'height' in node):
755-
path = os.path.join(self.builder.srcdir, olduri) # type: ignore[has-type]
755+
path = os.path.join(self.builder.srcdir, olduri)
756756
size = get_image_size(path)
757757
if size is None:
758758
logger.warning(

0 commit comments

Comments
 (0)