Disallow subclassing `Any` (#12638)

This commit is contained in:
danieleades
2024-07-23 01:52:20 +01:00
committed by GitHub
parent f8e9669f8b
commit e8f8247e0c
13 changed files with 17 additions and 16 deletions

View File

@@ -208,6 +208,7 @@ exclude = [
]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_defs = true
python_version = "3.10"
show_column_numbers = true

View File

@@ -5,7 +5,7 @@ from __future__ import annotations
from docutils.writers.latex2e import Babel
class ExtBabel(Babel):
class ExtBabel(Babel): # type: ignore[misc]
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
def __init__(self, language_code: str, use_polyglossia: bool = False) -> None:

View File

@@ -209,7 +209,7 @@ class Author(SphinxDirective):
return ret
class SeeAlso(BaseAdmonition):
class SeeAlso(BaseAdmonition): # type: ignore[misc]
"""
An admonition mentioning things to look at as reference.
"""

View File

@@ -27,7 +27,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
class Figure(images.Figure):
class Figure(images.Figure): # type: ignore[misc]
"""The figure directive which applies `:name:` option to the figure node
instead of the image node.
"""
@@ -53,7 +53,7 @@ class Figure(images.Figure):
return [figure_node]
class CSVTable(tables.CSVTable):
class CSVTable(tables.CSVTable): # type: ignore[misc]
"""The csv-table directive which searches a CSV file from Sphinx project's source
directory when an absolute path is given via :file: option.
"""

View File

@@ -43,7 +43,7 @@ class todolist(nodes.General, nodes.Element):
pass
class Todo(BaseAdmonition, SphinxDirective):
class Todo(BaseAdmonition, SphinxDirective): # type: ignore[misc]
"""
A todo entry, displayed (if configured) in the form of an admonition.
"""

View File

@@ -35,7 +35,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
class SphinxBaseReader(standalone.Reader):
class SphinxBaseReader(standalone.Reader): # type: ignore[misc]
"""
A base class of readers for Sphinx.
@@ -143,7 +143,7 @@ class SphinxI18nReader(SphinxBaseReader):
self.transforms.remove(transform)
class SphinxDummyWriter(UnfilteredWriter):
class SphinxDummyWriter(UnfilteredWriter): # type: ignore[misc]
"""Dummy writer module used for generating doctree."""
supported = ('html',) # needed to keep "meta" nodes

View File

@@ -20,7 +20,7 @@ HTMLTranslator = HTML5Translator
# https://www.arnebrodowski.de/blog/write-your-own-restructuredtext-writer.html
class HTMLWriter(Writer):
class HTMLWriter(Writer): # type: ignore[misc]
# override embed-stylesheet default value to False.
settings_default_overrides = {"embed_stylesheet": False}

View File

@@ -43,7 +43,7 @@ def multiply_length(length: str, scale: int) -> str:
return f"{int(result)}{unit}"
class HTML5Translator(SphinxTranslator, BaseTranslator):
class HTML5Translator(SphinxTranslator, BaseTranslator): # type: ignore[misc]
"""
Our custom HTML translator.
"""

View File

@@ -66,7 +66,7 @@ class UnsupportedError(SphinxError):
category = 'Markup is unsupported in LaTeX'
class LaTeXWriter(writers.Writer):
class LaTeXWriter(writers.Writer): # type: ignore[misc]
supported = ('sphinxlatex',)

View File

@@ -24,7 +24,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
class ManualPageWriter(Writer):
class ManualPageWriter(Writer): # type: ignore[misc]
def __init__(self, builder: Builder) -> None:
super().__init__()
self.builder = builder
@@ -70,7 +70,7 @@ class NestedInlineTransform:
node.parent.remove(node)
class ManualPageTranslator(SphinxTranslator, BaseTranslator):
class ManualPageTranslator(SphinxTranslator, BaseTranslator): # type: ignore[misc]
"""
Custom man page translator.
"""

View File

@@ -105,7 +105,7 @@ def smart_capwords(s: str, sep: str | None = None) -> str:
return (sep or ' ').join(words)
class TexinfoWriter(writers.Writer):
class TexinfoWriter(writers.Writer): # type: ignore[misc]
"""Texinfo writer for generating Texinfo documents."""
supported = ('texinfo', 'texi')

View File

@@ -356,7 +356,7 @@ def my_wrap(text: str, width: int = MAXWIDTH, **kwargs: Any) -> list[str]:
return w.wrap(text)
class TextWriter(writers.Writer):
class TextWriter(writers.Writer): # type: ignore[misc]
supported = ('text',)
settings_spec = ('No options here.', '', ())
settings_defaults: dict[str, Any] = {}

View File

@@ -10,7 +10,7 @@ if TYPE_CHECKING:
from sphinx.builders import Builder
class XMLWriter(BaseXMLWriter):
class XMLWriter(BaseXMLWriter): # type: ignore[misc]
output: str
def __init__(self, builder: Builder) -> None:
@@ -29,7 +29,7 @@ class XMLWriter(BaseXMLWriter):
return super().translate()
class PseudoXMLWriter(BaseXMLWriter):
class PseudoXMLWriter(BaseXMLWriter): # type: ignore[misc]
supported = ('pprint', 'pformat', 'pseudoxml')
"""Formats this writer supports."""