mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Disallow implicit re-export (#12653)
This commit is contained in:
@@ -207,11 +207,7 @@ exclude = [
|
||||
# tests/test_writers
|
||||
]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_defs = true
|
||||
python_version = "3.10"
|
||||
disallow_untyped_calls = true
|
||||
show_column_numbers = true
|
||||
show_error_context = true
|
||||
strict_optional = true
|
||||
@@ -219,6 +215,12 @@ warn_redundant_casts = true
|
||||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
disallow_any_generics = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_reexport = true
|
||||
extra_checks = true
|
||||
enable_error_code = [
|
||||
"type-arg",
|
||||
|
||||
@@ -19,7 +19,7 @@ from sphinx.domains.c._ids import _macroKeywords, _max_id
|
||||
from sphinx.domains.c._parser import DefinitionParser
|
||||
from sphinx.domains.c._symbol import Symbol, _DuplicateSymbolError
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.roles import SphinxRole, XRefRole
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.transforms import SphinxTransform
|
||||
from sphinx.transforms.post_transforms import ReferencesResolver
|
||||
from sphinx.util import logging
|
||||
@@ -29,7 +29,7 @@ from sphinx.util.cfamily import (
|
||||
anon_identifier_re,
|
||||
)
|
||||
from sphinx.util.docfields import Field, GroupedField, TypedField
|
||||
from sphinx.util.docutils import SphinxDirective
|
||||
from sphinx.util.docutils import SphinxDirective, SphinxRole
|
||||
from sphinx.util.nodes import make_refnode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -23,7 +23,7 @@ from sphinx.domains.cpp._parser import DefinitionParser
|
||||
from sphinx.domains.cpp._symbol import Symbol, _DuplicateSymbolError
|
||||
from sphinx.errors import NoUri
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.roles import SphinxRole, XRefRole
|
||||
from sphinx.roles import XRefRole
|
||||
from sphinx.transforms import SphinxTransform
|
||||
from sphinx.transforms.post_transforms import ReferencesResolver
|
||||
from sphinx.util import logging
|
||||
@@ -33,7 +33,7 @@ from sphinx.util.cfamily import (
|
||||
anon_identifier_re,
|
||||
)
|
||||
from sphinx.util.docfields import Field, GroupedField
|
||||
from sphinx.util.docutils import SphinxDirective
|
||||
from sphinx.util.docutils import SphinxDirective, SphinxRole
|
||||
from sphinx.util.nodes import make_refnode
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -17,10 +17,11 @@ from docutils.statemachine import StringList
|
||||
|
||||
import sphinx
|
||||
from sphinx.config import ENUM, Config
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.ext.autodoc.importer import get_class_members, import_module, import_object
|
||||
from sphinx.ext.autodoc.mock import ismock, mock, undecorate
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
from sphinx.pycode import ModuleAnalyzer
|
||||
from sphinx.util import inspect, logging
|
||||
from sphinx.util.docstrings import prepare_docstring, separate_metadata
|
||||
from sphinx.util.inspect import (
|
||||
|
||||
@@ -11,8 +11,9 @@ import typing
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING, NamedTuple
|
||||
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.ext.autodoc.mock import ismock, undecorate
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
from sphinx.pycode import ModuleAnalyzer
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.inspect import (
|
||||
getannotations,
|
||||
|
||||
@@ -69,13 +69,14 @@ import sphinx
|
||||
from sphinx import addnodes
|
||||
from sphinx.config import Config
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.ext.autodoc import INSTANCEATTR, Documenter
|
||||
from sphinx.ext.autodoc.directive import DocumenterBridge, Options
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.ext.autodoc import INSTANCEATTR, Documenter, Options
|
||||
from sphinx.ext.autodoc.directive import DocumenterBridge
|
||||
from sphinx.ext.autodoc.importer import import_module
|
||||
from sphinx.ext.autodoc.mock import mock
|
||||
from sphinx.locale import __
|
||||
from sphinx.project import Project
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
from sphinx.pycode import ModuleAnalyzer
|
||||
from sphinx.registry import SphinxComponentRegistry
|
||||
from sphinx.util import logging, rst
|
||||
from sphinx.util.docutils import (
|
||||
@@ -97,7 +98,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.extension import Extension
|
||||
from sphinx.util.typing import ExtensionMetadata, OptionSpec
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import sphinx.locale
|
||||
from sphinx import __display_version__, package_dir
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.config import Config
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.ext.autodoc.importer import import_module
|
||||
from sphinx.ext.autosummary import (
|
||||
ImportExceptionGroup,
|
||||
@@ -42,7 +43,7 @@ from sphinx.ext.autosummary import (
|
||||
import_ivar_by_name,
|
||||
)
|
||||
from sphinx.locale import __
|
||||
from sphinx.pycode import ModuleAnalyzer, PycodeError
|
||||
from sphinx.pycode import ModuleAnalyzer
|
||||
from sphinx.registry import SphinxComponentRegistry
|
||||
from sphinx.util import logging, rst
|
||||
from sphinx.util.inspect import getall, safe_getattr
|
||||
@@ -392,7 +393,7 @@ def _skip_member(app: Sphinx, obj: Any, name: str, objtype: str) -> bool:
|
||||
|
||||
|
||||
def _get_class_members(obj: Any) -> dict[str, Any]:
|
||||
members = sphinx.ext.autodoc.get_class_members(obj, None, safe_getattr)
|
||||
members = sphinx.ext.autodoc.importer.get_class_members(obj, None, safe_getattr)
|
||||
return {name: member.object for name, member in members.items()}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.config import Config
|
||||
from sphinx.util.typing import ExtensionMetadata, OptionSpec
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
from sphinx.writers.latex import LaTeXTranslator
|
||||
from sphinx.writers.manpage import ManualPageTranslator
|
||||
from sphinx.writers.texinfo import TexinfoTranslator
|
||||
|
||||
@@ -36,7 +36,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.builders import Builder
|
||||
from sphinx.config import Config
|
||||
from sphinx.util.typing import ExtensionMetadata
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.util.typing import ExtensionMetadata, OptionSpec
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
from sphinx.writers.latex import LaTeXTranslator
|
||||
from sphinx.writers.texinfo import TexinfoTranslator
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from sphinx.util.math import get_node_equation_number
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.util.typing import ExtensionMetadata
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
|
||||
# more information for mathjax secure url is here:
|
||||
# https://docs.mathjax.org/en/latest/web/start.html#using-mathjax-from-a-content-delivery-network-cdn
|
||||
|
||||
@@ -29,7 +29,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.util.typing import ExtensionMetadata, OptionSpec
|
||||
from sphinx.writers.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
from sphinx.writers.latex import LaTeXTranslator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -17,11 +17,11 @@ from importlib import import_module
|
||||
from inspect import Parameter, Signature
|
||||
from io import StringIO
|
||||
from types import ClassMethodDescriptorType, MethodDescriptorType, WrapperDescriptorType
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, ForwardRef
|
||||
|
||||
from sphinx.pycode.ast import unparse as ast_unparse
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.typing import ForwardRef, stringify_annotation
|
||||
from sphinx.util.typing import stringify_annotation
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable, Sequence
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
||||
if TYPE_CHECKING:
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.builders.html import HTML5Translator
|
||||
from sphinx.writers.html5 import HTML5Translator
|
||||
|
||||
|
||||
def get_node_equation_number(writer: HTML5Translator, node: nodes.math_block) -> str:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import gettext
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -19,14 +20,14 @@ if TYPE_CHECKING:
|
||||
|
||||
def _init_console(
|
||||
locale_dir: str | None = sphinx.locale._LOCALE_DIR, catalog: str = 'sphinx',
|
||||
) -> tuple[sphinx.locale.NullTranslations, bool]:
|
||||
) -> tuple[gettext.NullTranslations, bool]:
|
||||
"""Monkeypatch ``init_console`` to skip its action.
|
||||
|
||||
Some tests rely on warning messages in English. We don't want
|
||||
CLI tests to bleed over those tests and make their warnings
|
||||
translated.
|
||||
"""
|
||||
return sphinx.locale.NullTranslations(), False
|
||||
return gettext.NullTranslations(), False
|
||||
|
||||
|
||||
sphinx.locale.init_console = _init_console
|
||||
|
||||
@@ -6,7 +6,8 @@ import tempfile
|
||||
import pytest
|
||||
|
||||
from sphinx.errors import ExtensionError
|
||||
from sphinx.util import encode_uri, ensuredir, import_object, parselinenos
|
||||
from sphinx.util import encode_uri, import_object, parselinenos
|
||||
from sphinx.util.osutil import ensuredir
|
||||
|
||||
|
||||
def test_encode_uri():
|
||||
|
||||
Reference in New Issue
Block a user