Use `types.NoneType` (#12659)

This commit is contained in:
Adam Turner
2024-07-23 01:31:53 +01:00
committed by GitHub
parent 3b009cd627
commit c8c7fee4e5
3 changed files with 6 additions and 11 deletions

View File

@@ -38,7 +38,6 @@ if TYPE_CHECKING:
from sphinx.config import Config
from sphinx.events import EventManager
from sphinx.util.tags import Tags
from sphinx.util.typing import NoneType
logger = logging.getLogger(__name__)
@@ -645,7 +644,7 @@ class Builder:
progress = status_iterator(chunks, __('writing output... '), "darkgreen",
len(chunks), self.app.verbosity)
def on_chunk_done(args: list[tuple[str, NoneType]], result: NoneType) -> None:
def on_chunk_done(args: list[tuple[str, nodes.document]], result: None) -> None:
next(progress)
self.app.phase = BuildPhase.RESOLVING

View File

@@ -15,7 +15,6 @@ from sphinx.errors import ConfigError, ExtensionError
from sphinx.locale import _, __
from sphinx.util import logging
from sphinx.util.osutil import fs_encoding
from sphinx.util.typing import ExtensionMetadata, NoneType
if sys.version_info >= (3, 11):
from contextlib import chdir
@@ -30,7 +29,7 @@ if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.util.tags import Tags
from sphinx.util.typing import _ExtensionSetupFunc
from sphinx.util.typing import ExtensionMetadata, _ExtensionSetupFunc
logger = logging.getLogger(__name__)
@@ -250,7 +249,7 @@ class Config:
'rst_epilog': _Opt(None, 'env', frozenset((str,))),
'rst_prolog': _Opt(None, 'env', frozenset((str,))),
'trim_doctest_flags': _Opt(True, 'env', ()),
'primary_domain': _Opt('py', 'env', frozenset((NoneType,))),
'primary_domain': _Opt('py', 'env', frozenset((types.NoneType,))),
'needs_sphinx': _Opt(None, '', frozenset((str,))),
'needs_extensions': _Opt({}, '', ()),
'manpages_url': _Opt(None, 'env', ()),
@@ -261,7 +260,7 @@ class Config:
'numfig_secnum_depth': _Opt(1, 'env', ()),
'numfig_format': _Opt({}, 'env', ()), # will be initialized in init_numfig_format()
'maximum_signature_line_length': _Opt(
None, 'env', frozenset((int, NoneType))),
None, 'env', frozenset((int, types.NoneType))),
'math_number_all': _Opt(False, 'env', ()),
'math_eqref_format': _Opt(None, 'env', frozenset((str,))),
'math_numfig': _Opt(True, 'env', ()),

View File

@@ -83,9 +83,6 @@ def is_invalid_builtin_class(obj: Any) -> bool:
# Text like nodes which are initialized with text and rawsource
TextlikeNode: TypeAlias = nodes.Text | nodes.TextElement
# type of None
NoneType: TypeAlias = type(None) # type: ignore[no-redef]
# path matcher
PathMatcher: TypeAlias = Callable[[str], bool]
@@ -237,7 +234,7 @@ def restify(cls: Any, mode: _RestifyMode = 'fully-qualified-except-typing') -> s
raise ValueError(msg)
# things that are not types
if cls is None or cls == NoneType:
if cls is None or cls == types.NoneType:
return ':py:obj:`None`'
if cls is Ellipsis:
return '...'
@@ -397,7 +394,7 @@ def stringify_annotation(
raise ValueError(msg)
# things that are not types
if annotation is None or annotation == NoneType:
if annotation is None or annotation == types.NoneType:
return 'None'
if annotation is Ellipsis:
return '...'