mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use type hints for directories
This commit is contained in:
parent
1266c421be
commit
2ccbc3209a
@ -48,6 +48,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.config import Config
|
||||
from sphinx.events import EventManager
|
||||
from sphinx.util._pathlib import _StrPath
|
||||
from sphinx.util.tags import Tags
|
||||
|
||||
|
||||
@ -94,10 +95,10 @@ class Builder:
|
||||
supported_data_uri_images: bool = False
|
||||
|
||||
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
|
||||
self.srcdir = app.srcdir
|
||||
self.confdir = app.confdir
|
||||
self.outdir = app.outdir
|
||||
self.doctreedir = app.doctreedir
|
||||
self.srcdir: _StrPath = app.srcdir
|
||||
self.confdir: _StrPath = app.confdir
|
||||
self.outdir: _StrPath = app.outdir
|
||||
self.doctreedir: _StrPath = app.doctreedir
|
||||
ensuredir(self.doctreedir)
|
||||
|
||||
self.app: Sphinx = app
|
||||
|
@ -32,7 +32,6 @@ from sphinx.util.osutil import _last_modified_time, canon_path, os_path
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from pathlib import Path
|
||||
from typing import Any, Literal
|
||||
|
||||
from docutils import nodes
|
||||
@ -102,8 +101,8 @@ class BuildEnvironment:
|
||||
|
||||
def __init__(self, app: Sphinx) -> None:
|
||||
self.app: Sphinx = app
|
||||
self.doctreedir: Path = app.doctreedir
|
||||
self.srcdir: Path = app.srcdir
|
||||
self.doctreedir: _StrPath = app.doctreedir
|
||||
self.srcdir: _StrPath = app.srcdir
|
||||
self.config: Config = None # type: ignore[assignment]
|
||||
self.config_status: int = CONFIG_UNSET
|
||||
self.config_status_extra: str = ''
|
||||
|
@ -752,7 +752,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator): # type: ignore[misc]
|
||||
# but it tries the final file name, which does not necessarily exist
|
||||
# yet at the time the HTML file is written.
|
||||
if not ('width' in node and 'height' in node):
|
||||
path = os.path.join(self.builder.srcdir, olduri) # type: ignore[has-type]
|
||||
path = os.path.join(self.builder.srcdir, olduri)
|
||||
size = get_image_size(path)
|
||||
if size is None:
|
||||
logger.warning(
|
||||
|
Loading…
Reference in New Issue
Block a user