mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix various Ruff errors
This commit is contained in:
@@ -10,7 +10,6 @@ from __future__ import annotations
|
||||
import re
|
||||
import sys
|
||||
from inspect import Parameter, Signature
|
||||
from types import ModuleType
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
@@ -45,6 +44,8 @@ from sphinx.util.inspect import (
|
||||
from sphinx.util.typing import OptionSpec, get_type_hints, restify, stringify_annotation
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import ModuleType
|
||||
|
||||
from sphinx.ext.autodoc.directive import DocumenterBridge
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -22,9 +22,8 @@ import pkgutil
|
||||
import pydoc
|
||||
import re
|
||||
import sys
|
||||
from gettext import NullTranslations
|
||||
from os import path
|
||||
from typing import Any, NamedTuple, Sequence
|
||||
from typing import TYPE_CHECKING, Any, NamedTuple, Sequence
|
||||
|
||||
from jinja2 import TemplateNotFound
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
@@ -50,6 +49,9 @@ from sphinx.util.inspect import getall, safe_getattr
|
||||
from sphinx.util.osutil import ensuredir
|
||||
from sphinx.util.template import SphinxTemplateLoader
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from gettext import NullTranslations
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
from os import path
|
||||
from types import ModuleType
|
||||
from typing import IO, Any, cast
|
||||
from typing import IO, TYPE_CHECKING, Any, cast
|
||||
from urllib.parse import urlsplit, urlunsplit
|
||||
|
||||
from docutils import nodes
|
||||
@@ -48,6 +47,9 @@ from sphinx.util.docutils import CustomReSTDispatcher, SphinxRole
|
||||
from sphinx.util.inventory import InventoryFile
|
||||
from sphinx.util.typing import Inventory, InventoryItem, RoleFunction
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import ModuleType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -6,14 +6,16 @@ import re
|
||||
import tokenize
|
||||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
from inspect import Signature
|
||||
from os import path
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from zipfile import ZipFile
|
||||
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.pycode.parser import Parser
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from inspect import Signature
|
||||
|
||||
|
||||
class ModuleAnalyzer:
|
||||
annotations: dict[tuple[str, str], str]
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import builtins
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from typing import IO, Any, Callable
|
||||
from typing import IO, TYPE_CHECKING, Any, Callable
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import builtins
|
||||
|
||||
FILESYSTEMENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
from io import StringIO
|
||||
from typing import IO, Any, Generator
|
||||
from typing import IO, TYPE_CHECKING, Any, Generator
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from docutils import nodes
|
||||
@@ -19,6 +18,9 @@ from sphinx.pycode import ModuleAnalyzer
|
||||
from sphinx.testing.path import path
|
||||
from sphinx.util.osutil import relpath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from io import StringIO
|
||||
|
||||
__all__ = [
|
||||
'Struct', 'SphinxTestApp', 'SphinxTestAppWrapperForSkipBuilding',
|
||||
]
|
||||
|
||||
@@ -8,7 +8,7 @@ from sphinx.util import logging
|
||||
from sphinx.util.console import bold, colorize, term_width_line # type: ignore
|
||||
|
||||
if False:
|
||||
from types import TracebackType
|
||||
from types import TracebackType # NoQA: TCH003
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import warnings
|
||||
from contextlib import contextmanager
|
||||
from copy import copy
|
||||
from os import path
|
||||
from types import ModuleType
|
||||
from typing import IO, TYPE_CHECKING, Any, Callable, Generator, cast
|
||||
|
||||
import docutils
|
||||
@@ -30,6 +29,8 @@ logger = logging.getLogger(__name__)
|
||||
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) ')
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from types import ModuleType
|
||||
|
||||
from docutils.frontend import Values
|
||||
|
||||
from sphinx.builders import Builder
|
||||
|
||||
@@ -28,13 +28,13 @@ def test_dirhtml(app, status, warning):
|
||||
invdata = InventoryFile.load(f, 'path/to', posixpath.join)
|
||||
|
||||
assert 'index' in invdata.get('std:doc')
|
||||
assert ('Python', '', 'path/to/', '-') == invdata['std:doc']['index']
|
||||
assert invdata['std:doc']['index'] == ('Python', '', 'path/to/', '-')
|
||||
|
||||
assert 'foo/index' in invdata.get('std:doc')
|
||||
assert ('Python', '', 'path/to/foo/', '-') == invdata['std:doc']['foo/index']
|
||||
assert invdata['std:doc']['foo/index'] == ('Python', '', 'path/to/foo/', '-')
|
||||
|
||||
assert 'index' in invdata.get('std:label')
|
||||
assert ('Python', '', 'path/to/#index', '-') == invdata['std:label']['index']
|
||||
assert invdata['std:label']['index'] == ('Python', '', 'path/to/#index', '-')
|
||||
|
||||
assert 'foo' in invdata.get('std:label')
|
||||
assert ('Python', '', 'path/to/foo/#foo', 'foo/index') == invdata['std:label']['foo']
|
||||
assert invdata['std:label']['foo'] == ('Python', '', 'path/to/foo/#foo', 'foo/index')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from inspect import Signature
|
||||
from numbers import Integral
|
||||
from numbers import Integral # NoQA: TCH003
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user