diff options
author | danieleades <33452915+danieleades@users.noreply.github.com> | 2023-01-02 05:29:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-02 05:29:46 +0000 |
commit | dbf36f8b379f1e60232ecbf85a67e6ab9b096f24 (patch) | |
tree | 1f83792972910e5e51bd4fda81240bbf6c2264bc | |
parent | c2e278520e8f84705d967f71279b71c21c7d7886 (diff) | |
download | sphinx-git-dbf36f8b379f1e60232ecbf85a67e6ab9b096f24.tar.gz |
Shrink 'any-generics' whitelist for 'writers' module (#10867)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
-rw-r--r-- | pyproject.toml | 1 | ||||
-rw-r--r-- | sphinx/writers/latex.py | 4 | ||||
-rw-r--r-- | sphinx/writers/texinfo.py | 11 | ||||
-rw-r--r-- | sphinx/writers/text.py | 4 |
4 files changed, 11 insertions, 9 deletions
diff --git a/pyproject.toml b/pyproject.toml index dc0aa8a6c..70b44edaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -278,7 +278,6 @@ module = [ "sphinx.search.*", "sphinx.testing.*", "sphinx.util.*", - "sphinx.writers.*", ] disallow_any_generics = false diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index c6c63828b..7e78ea2ed 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -74,7 +74,7 @@ class LaTeXWriter(writers.Writer): ('Document class', ['--docclass'], {'default': 'manual'}), ('Author', ['--author'], {'default': ''}), )) - settings_defaults: dict = {} + settings_defaults: dict[str, Any] = {} output = None @@ -512,7 +512,7 @@ class LaTeXTranslator(SphinxTranslator): return ''.join(ret) - def render(self, template_name: str, variables: dict) -> str: + def render(self, template_name: str, variables: dict[str, Any]) -> str: renderer = LaTeXRenderer(latex_engine=self.config.latex_engine) for template_dir in self.config.templates_path: template = path.join(self.builder.confdir, template_dir, diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 33ae2574b..1d72e4130 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -114,9 +114,9 @@ class TexinfoWriter(writers.Writer): ('Category', ['--texinfo-dir-category'], {'default': 'Miscellaneous'}))) - settings_defaults: dict = {} + settings_defaults: dict[str, Any] = {} - output: str | None = None # type: ignore[assignment] + output: str visitor_attributes = ('output', 'fragment') @@ -391,8 +391,11 @@ class TexinfoTranslator(SphinxTranslator): textwrap.wrap(desc, width=78 - offset)) return s + wdesc.strip() + '\n' - def add_menu_entries(self, entries: list[str], reg: re.Pattern = re.compile(r'\s+---?\s+') - ) -> None: + def add_menu_entries( + self, + entries: list[str], + reg: re.Pattern[str] = re.compile(r'\s+---?\s+'), + ) -> None: for entry in entries: name = self.node_names[entry] # special formatting for entries that are divided by an em-dash diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py index ded21fb2f..7ac2359c8 100644 --- a/sphinx/writers/text.py +++ b/sphinx/writers/text.py @@ -356,7 +356,7 @@ def my_wrap(text: str, width: int = MAXWIDTH, **kwargs: Any) -> list[str]: class TextWriter(writers.Writer): supported = ('text',) settings_spec = ('No options here.', '', ()) - settings_defaults: dict = {} + settings_defaults: dict[str, Any] = {} output: str = None @@ -371,7 +371,7 @@ class TextWriter(writers.Writer): class TextTranslator(SphinxTranslator): - builder: TextBuilder = None + builder: TextBuilder def __init__(self, document: nodes.document, builder: TextBuilder) -> None: super().__init__(document, builder) |