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.application import Sphinx
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
from sphinx.events import EventManager
|
from sphinx.events import EventManager
|
||||||
|
from sphinx.util._pathlib import _StrPath
|
||||||
from sphinx.util.tags import Tags
|
from sphinx.util.tags import Tags
|
||||||
|
|
||||||
|
|
||||||
@ -94,10 +95,10 @@ class Builder:
|
|||||||
supported_data_uri_images: bool = False
|
supported_data_uri_images: bool = False
|
||||||
|
|
||||||
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
|
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
|
||||||
self.srcdir = app.srcdir
|
self.srcdir: _StrPath = app.srcdir
|
||||||
self.confdir = app.confdir
|
self.confdir: _StrPath = app.confdir
|
||||||
self.outdir = app.outdir
|
self.outdir: _StrPath = app.outdir
|
||||||
self.doctreedir = app.doctreedir
|
self.doctreedir: _StrPath = app.doctreedir
|
||||||
ensuredir(self.doctreedir)
|
ensuredir(self.doctreedir)
|
||||||
|
|
||||||
self.app: Sphinx = app
|
self.app: Sphinx = app
|
||||||
|
@ -32,7 +32,6 @@ from sphinx.util.osutil import _last_modified_time, canon_path, os_path
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Callable, Iterable, Iterator
|
from collections.abc import Callable, Iterable, Iterator
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any, Literal
|
from typing import Any, Literal
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
@ -102,8 +101,8 @@ class BuildEnvironment:
|
|||||||
|
|
||||||
def __init__(self, app: Sphinx) -> None:
|
def __init__(self, app: Sphinx) -> None:
|
||||||
self.app: Sphinx = app
|
self.app: Sphinx = app
|
||||||
self.doctreedir: Path = app.doctreedir
|
self.doctreedir: _StrPath = app.doctreedir
|
||||||
self.srcdir: Path = app.srcdir
|
self.srcdir: _StrPath = app.srcdir
|
||||||
self.config: Config = None # type: ignore[assignment]
|
self.config: Config = None # type: ignore[assignment]
|
||||||
self.config_status: int = CONFIG_UNSET
|
self.config_status: int = CONFIG_UNSET
|
||||||
self.config_status_extra: str = ''
|
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
|
# but it tries the final file name, which does not necessarily exist
|
||||||
# yet at the time the HTML file is written.
|
# yet at the time the HTML file is written.
|
||||||
if not ('width' in node and 'height' in node):
|
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)
|
size = get_image_size(path)
|
||||||
if size is None:
|
if size is None:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
Loading…
Reference in New Issue
Block a user