Skip to content

Commit

Permalink
Expand all any-generics overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 19, 2024
1 parent 7c24d40 commit a9ba9f9
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 39 deletions.
22 changes: 18 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,29 @@ module = [
"sphinx.domains",
"sphinx.domains.c",
"sphinx.domains.cpp",
"sphinx.environment.*",
"sphinx.environment",
"sphinx.environment.adapters.indexentries",
"sphinx.environment.collectors.toctree",
"sphinx.events",
"sphinx.ext.*",
"sphinx.ext.autodoc",
"sphinx.ext.autodoc.directive",
"sphinx.ext.autodoc.importer",
"sphinx.ext.autodoc.mock",
"sphinx.ext.autodoc.mock",
"sphinx.ext.autosummary.generate",
"sphinx.ext.doctest",
"sphinx.ext.graphviz",
"sphinx.ext.inheritance_diagram",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon.docstring",
"sphinx.highlighting",
"sphinx.jinja2glue",
"sphinx.registry",
"sphinx.roles",
"sphinx.search.*",
"sphinx.testing.*",
"sphinx.search",
"sphinx.testing.fixtures",
"sphinx.testing.path",
"sphinx.testing.util",
"sphinx.util",
"sphinx.util.display",
"sphinx.util.docfields",
Expand Down
2 changes: 1 addition & 1 deletion sphinx/domains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def clear_doc(self, docname: str) -> None:
"""Remove traces of a document in the domain-specific inventories."""
pass

def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
def merge_domaindata(self, docnames: list[str], otherdata: dict[str, Any]) -> None:
"""Merge in data regarding *docnames* from a different domaindata
inventory (coming from a subprocess in parallel builds).
"""
Expand Down
2 changes: 1 addition & 1 deletion sphinx/domains/c/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def process_doc(self, env: BuildEnvironment, docname: str,
def process_field_xref(self, pnode: pending_xref) -> None:
pnode.attributes.update(self.env.ref_context)

def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
def merge_domaindata(self, docnames: list[str], otherdata: dict[str, Any]) -> None:
if Symbol.debug_show_tree:
logger.debug("merge_domaindata:")
logger.debug("\tself:")
Expand Down
2 changes: 1 addition & 1 deletion sphinx/domains/cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ def process_doc(self, env: BuildEnvironment, docname: str,
def process_field_xref(self, pnode: pending_xref) -> None:
pnode.attributes.update(self.env.ref_context)

def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
def merge_domaindata(self, docnames: list[str], otherdata: dict[str, Any]) -> None:
if Symbol.debug_show_tree:
logger.debug("merge_domaindata:")
logger.debug("\tself:")
Expand Down
3 changes: 2 additions & 1 deletion sphinx/ext/autodoc/typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
from sphinx.util.typing import stringify_annotation

if TYPE_CHECKING:
from sphinx.ext.autodoc import Options
from docutils.nodes import Element

from sphinx.application import Sphinx


def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any,
options: dict, args: str, retann: str) -> None:
options: Options, args: str, retann: str) -> None:
"""Record type hints to env object."""
if app.config.autodoc_typehints_format == 'short':
mode = 'smart'
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/extlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def make_link_role(name: str, base_url: str, caption: str) -> RoleFunction:
# Remark: It is an implementation detail that we use Pythons %-formatting.
# So far we only expose ``%s`` and require quoting of ``%`` using ``%%``.
def role(typ: str, rawtext: str, text: str, lineno: int,
inliner: Inliner, options: dict | None = None, content: Sequence[str] = (),
inliner: Inliner, options: dict[str, Any] | None = None, content: Sequence[str] = (),
) -> tuple[list[Node], list[system_message]]:
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def todos(self) -> dict[str, list[todo_node]]:
def clear_doc(self, docname: str) -> None:
self.todos.pop(docname, None)

def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
def merge_domaindata(self, docnames: list[str], otherdata: dict[str, Any]) -> None:
for docname in docnames:
self.todos[docname] = otherdata['todos'][docname]

Expand Down
14 changes: 7 additions & 7 deletions sphinx/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class SearchLanguage:

_word_re = re.compile(r'\w+')

def __init__(self, options: dict) -> None:
def __init__(self, options: dict[str, str]) -> None:
self.options = options
self.init(options)

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
"""
Initialize the class with the options the user has given.
"""
Expand Down Expand Up @@ -171,10 +171,10 @@ def loads(self, s: str) -> Any:
raise ValueError('invalid data')
return json.loads(data)

def dump(self, data: Any, f: IO) -> None:
def dump(self, data: Any, f: IO[str]) -> None:
f.write(self.dumps(data))

def load(self, f: IO) -> Any:
def load(self, f: IO[str]) -> Any:
return self.loads(f.read())


Expand Down Expand Up @@ -250,7 +250,7 @@ class IndexBuilder:
'pickle': pickle
}

def __init__(self, env: BuildEnvironment, lang: str, options: dict, scoring: str) -> None:
def __init__(self, env: BuildEnvironment, lang: str, options: dict[str, str], scoring: str) -> None:
self.env = env
# docname -> title
self._titles: dict[str, str] = env._search_index_titles
Expand Down Expand Up @@ -368,8 +368,8 @@ def get_objects(self, fn2index: dict[str, int]
plist.append((fn2index[docname], typeindex, prio, shortanchor, name))
return rv

def get_terms(self, fn2index: dict) -> tuple[dict[str, list[str]], dict[str, list[str]]]:
rvs: tuple[dict[str, list[str]], dict[str, list[str]]] = ({}, {})
def get_terms(self, fn2index: dict[str, int]) -> tuple[dict[str, list[int] | int], dict[str, list[int] | int]]:
rvs: tuple[dict[str, list[int] | int], dict[str, list[int] | int]] = ({}, {})
for rv, mapping in zip(rvs, (self._mapping, self._title_mapping)):
for k, v in mapping.items():
if len(v) == 1:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/da.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SearchDanish(SearchLanguage):
js_stemmer_rawcode = 'danish-stemmer.js'
stopwords = danish_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('danish')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class SearchGerman(SearchLanguage):
js_stemmer_rawcode = 'german-stemmer.js'
stopwords = german_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('german')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class SearchEnglish(SearchLanguage):
js_stemmer_code = js_porter_stemmer
stopwords = english_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('porter')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class SearchSpanish(SearchLanguage):
js_stemmer_rawcode = 'spanish-stemmer.js'
stopwords = spanish_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('spanish')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/fi.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SearchFinnish(SearchLanguage):
js_stemmer_rawcode = 'finnish-stemmer.js'
stopwords = finnish_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('finnish')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class SearchFrench(SearchLanguage):
js_stemmer_rawcode = 'french-stemmer.js'
stopwords = french_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('french')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/hu.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SearchHungarian(SearchLanguage):
js_stemmer_rawcode = 'hungarian-stemmer.js'
stopwords = hungarian_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('hungarian')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/it.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class SearchItalian(SearchLanguage):
js_stemmer_rawcode = 'italian-stemmer.js'
stopwords = italian_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('italian')

def stem(self, word: str) -> str:
Expand Down
12 changes: 6 additions & 6 deletions sphinx/search/ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


class BaseSplitter:
def __init__(self, options: dict) -> None:
def __init__(self, options: dict[str, str]) -> None:
self.options = options

def split(self, input: str) -> list[str]:
Expand All @@ -46,7 +46,7 @@ def split(self, input: str) -> list[str]:


class MecabSplitter(BaseSplitter):
def __init__(self, options: dict) -> None:
def __init__(self, options: dict[str, str]) -> None:
super().__init__(options)
self.ctypes_libmecab: Any = None
self.ctypes_mecab: Any = None
Expand All @@ -64,14 +64,14 @@ def split(self, input: str) -> list[str]:
self.ctypes_mecab, input.encode(self.dict_encode))
return result.split(' ')

def init_native(self, options: dict) -> None:
def init_native(self, options: dict[str, str]) -> None:
param = '-Owakati'
dict = options.get('dict')
if dict:
param += ' -d %s' % dict
self.native = MeCab.Tagger(param)

def init_ctypes(self, options: dict) -> None:
def init_ctypes(self, options: dict[str, str]) -> None:
import ctypes.util

lib = options.get('lib')
Expand Down Expand Up @@ -113,7 +113,7 @@ def __del__(self) -> None:


class JanomeSplitter(BaseSplitter):
def __init__(self, options: dict) -> None:
def __init__(self, options: dict[str, str]) -> None:
super().__init__(options)
self.user_dict = options.get('user_dic')
self.user_dict_enc = options.get('user_dic_enc', 'utf8')
Expand Down Expand Up @@ -513,7 +513,7 @@ class SearchJapanese(SearchLanguage):
lang = 'ja'
language_name = 'Japanese'

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
dotted_path = options.get('type', 'sphinx.search.ja.DefaultSplitter')
try:
self.splitter = import_object(dotted_path)(options)
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/nl.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class SearchDutch(SearchLanguage):
js_stemmer_rawcode = 'dutch-stemmer.js'
stopwords = dutch_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('dutch')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/no.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class SearchNorwegian(SearchLanguage):
js_stemmer_rawcode = 'norwegian-stemmer.js'
stopwords = norwegian_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('norwegian')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class SearchPortuguese(SearchLanguage):
js_stemmer_rawcode = 'portuguese-stemmer.js'
stopwords = portuguese_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('portuguese')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/ro.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SearchRomanian(SearchLanguage):
js_stemmer_rawcode = 'romanian-stemmer.js'
stopwords: set[str] = set()

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('romanian')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class SearchRussian(SearchLanguage):
js_stemmer_rawcode = 'russian-stemmer.js'
stopwords = russian_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('russian')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/sv.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SearchSwedish(SearchLanguage):
js_stemmer_rawcode = 'swedish-stemmer.js'
stopwords = swedish_stopwords

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('swedish')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/tr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SearchTurkish(SearchLanguage):
js_stemmer_rawcode = 'turkish-stemmer.js'
stopwords: set[str] = set()

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
self.stemmer = snowballstemmer.stemmer('turkish')

def stem(self, word: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/search/zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class SearchChinese(SearchLanguage):
latin1_letters = re.compile(r'[a-zA-Z0-9_]+')
latin_terms: list[str] = []

def init(self, options: dict) -> None:
def init(self, options: dict[str, str]) -> None:
if JIEBA:
dict_path = options.get('dict')
if dict_path and os.path.isfile(dict_path):
Expand Down

0 comments on commit a9ba9f9

Please sign in to comment.