mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Update typing ignores for mypy 0.990
This commit is contained in:
parent
a6032e852a
commit
cd3f2e4350
@ -85,7 +85,7 @@ lint = [
|
||||
"flake8-bugbear",
|
||||
"flake8-simplify",
|
||||
"isort",
|
||||
"mypy>=0.981",
|
||||
"mypy>=0.990",
|
||||
"sphinx-lint",
|
||||
"docutils-stubs",
|
||||
"types-requests",
|
||||
|
@ -1014,7 +1014,7 @@ class Sphinx:
|
||||
|
||||
self.registry.add_js_file(filename, priority=priority, **kwargs)
|
||||
if hasattr(self, 'builder') and hasattr(self.builder, 'add_js_file'):
|
||||
self.builder.add_js_file(filename, # type: ignore[attr-defined]
|
||||
self.builder.add_js_file(filename,
|
||||
priority=priority, **kwargs)
|
||||
|
||||
def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None:
|
||||
@ -1077,7 +1077,7 @@ class Sphinx:
|
||||
logger.debug('[app] adding stylesheet: %r', filename)
|
||||
self.registry.add_css_files(filename, priority=priority, **kwargs)
|
||||
if hasattr(self, 'builder') and hasattr(self.builder, 'add_css_file'):
|
||||
self.builder.add_css_file(filename, # type: ignore[attr-defined]
|
||||
self.builder.add_css_file(filename,
|
||||
priority=priority, **kwargs)
|
||||
|
||||
def add_latex_package(self, packagename: str, options: Optional[str] = None,
|
||||
|
@ -57,7 +57,7 @@ class Catalog:
|
||||
line = origin.line
|
||||
if line is None:
|
||||
line = -1
|
||||
self.metadata[msg].append((origin.source, line, origin.uid)) # type: ignore
|
||||
self.metadata[msg].append((origin.source, line, origin.uid))
|
||||
|
||||
def __iter__(self) -> Generator[Message, None, None]:
|
||||
for message in self.messages:
|
||||
|
@ -551,7 +551,7 @@ def main(argv: List[str] = sys.argv[1:]) -> int:
|
||||
try:
|
||||
args = parser.parse_args(argv)
|
||||
except SystemExit as err:
|
||||
return err.code
|
||||
return err.code # type: ignore[return-value]
|
||||
|
||||
d = vars(args)
|
||||
# delete None or False value
|
||||
|
@ -285,7 +285,7 @@ class DefaultRole(SphinxDirective):
|
||||
role_name = self.arguments[0]
|
||||
role, messages = roles.role(role_name, self.state_machine.language,
|
||||
self.lineno, self.state.reporter)
|
||||
if role:
|
||||
if role: # type: ignore[truthy-function]
|
||||
docutils.register_role('', role)
|
||||
self.env.temp_data['default_role'] = role_name
|
||||
else:
|
||||
|
@ -249,7 +249,7 @@ class TocTree:
|
||||
if hasattr(toctree, 'uid'):
|
||||
# move uid to caption_node to translate it
|
||||
caption_node.uid = toctree.uid # type: ignore
|
||||
del toctree.uid # type: ignore
|
||||
del toctree.uid
|
||||
newnode += caption_node
|
||||
newnode.extend(tocentries)
|
||||
newnode['toctree'] = True
|
||||
|
@ -225,7 +225,7 @@ def render_dot(self: SphinxTranslator, code: str, options: Dict, format: str,
|
||||
return relfn, outfn
|
||||
|
||||
if (hasattr(self.builder, '_graphviz_warned_dot') and
|
||||
self.builder._graphviz_warned_dot.get(graphviz_dot)): # type: ignore[attr-defined]
|
||||
self.builder._graphviz_warned_dot.get(graphviz_dot)):
|
||||
return None, None
|
||||
|
||||
ensuredir(path.dirname(outfn))
|
||||
|
@ -278,7 +278,7 @@ def clean_up_files(app: Sphinx, exc: Exception) -> None:
|
||||
|
||||
if hasattr(app.builder, '_imgmath_tempdir'):
|
||||
try:
|
||||
shutil.rmtree(app.builder._imgmath_tempdir) # type: ignore
|
||||
shutil.rmtree(app.builder._imgmath_tempdir)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
@ -167,7 +167,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: Any) -> Any:
|
||||
raise
|
||||
try:
|
||||
if hasattr(f, 'url'):
|
||||
newinv = f.url # type: ignore
|
||||
newinv = f.url
|
||||
if inv != newinv:
|
||||
logger.info(__('intersphinx inventory has moved: %s -> %s'), inv, newinv)
|
||||
|
||||
|
@ -136,7 +136,7 @@ def env_merge_info(app: Sphinx, env: BuildEnvironment, docnames: Iterable[str],
|
||||
if not hasattr(env, '_viewcode_modules'):
|
||||
env._viewcode_modules = {} # type: ignore
|
||||
# now merge in the information from the subprocess
|
||||
for modname, entry in other._viewcode_modules.items(): # type: ignore
|
||||
for modname, entry in other._viewcode_modules.items():
|
||||
if modname not in env._viewcode_modules: # type: ignore
|
||||
env._viewcode_modules[modname] = entry # type: ignore
|
||||
else:
|
||||
@ -228,12 +228,12 @@ def collect_pages(app: Sphinx) -> Generator[Tuple[str, Dict[str, Any], str], Non
|
||||
highlighter = app.builder.highlighter # type: ignore
|
||||
urito = app.builder.get_relative_uri
|
||||
|
||||
modnames = set(env._viewcode_modules) # type: ignore
|
||||
modnames = set(env._viewcode_modules)
|
||||
|
||||
for modname, entry in status_iterator(
|
||||
sorted(env._viewcode_modules.items()), # type: ignore
|
||||
sorted(env._viewcode_modules.items()),
|
||||
__('highlighting module code... '), "blue",
|
||||
len(env._viewcode_modules), # type: ignore
|
||||
len(env._viewcode_modules),
|
||||
app.verbosity, lambda x: x[0]):
|
||||
if not entry:
|
||||
continue
|
||||
|
@ -350,9 +350,9 @@ class VariableCommentPicker(ast.NodeVisitor):
|
||||
return # this assignment is not new definition!
|
||||
|
||||
# record annotation
|
||||
if hasattr(node, 'annotation') and node.annotation: # type: ignore
|
||||
if hasattr(node, 'annotation') and node.annotation:
|
||||
for varname in varnames:
|
||||
self.add_variable_annotation(varname, node.annotation) # type: ignore
|
||||
self.add_variable_annotation(varname, node.annotation)
|
||||
elif hasattr(node, 'type_comment') and node.type_comment:
|
||||
for varname in varnames:
|
||||
self.add_variable_annotation(varname, node.type_comment) # type: ignore
|
||||
|
@ -52,7 +52,7 @@ def unwrap_all(obj: Any, *, stop: Optional[Callable] = None) -> Any:
|
||||
elif ispartial(obj):
|
||||
obj = obj.func
|
||||
elif inspect.isroutine(obj) and hasattr(obj, '__wrapped__'):
|
||||
obj = obj.__wrapped__ # type: ignore
|
||||
obj = obj.__wrapped__
|
||||
elif isclassmethod(obj):
|
||||
obj = obj.__func__
|
||||
elif isstaticmethod(obj):
|
||||
@ -278,7 +278,7 @@ def is_singledispatch_function(obj: Any) -> bool:
|
||||
if (inspect.isfunction(obj) and
|
||||
hasattr(obj, 'dispatch') and
|
||||
hasattr(obj, 'register') and
|
||||
obj.dispatch.__module__ == 'functools'): # type: ignore
|
||||
obj.dispatch.__module__ == 'functools'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -336,10 +336,10 @@ def isgenericalias(obj: Any) -> bool:
|
||||
if isinstance(obj, typing._GenericAlias): # type: ignore
|
||||
return True
|
||||
elif (hasattr(types, 'GenericAlias') and # only for py39+
|
||||
isinstance(obj, types.GenericAlias)): # type: ignore
|
||||
isinstance(obj, types.GenericAlias)):
|
||||
return True
|
||||
elif (hasattr(typing, '_SpecialGenericAlias') and # for py39+
|
||||
isinstance(obj, typing._SpecialGenericAlias)): # type: ignore
|
||||
isinstance(obj, typing._SpecialGenericAlias)):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -19,7 +19,7 @@ useragent_header = [('User-Agent',
|
||||
@contextmanager
|
||||
def ignore_insecure_warning(**kwargs: Any) -> Generator[None, None, None]:
|
||||
with warnings.catch_warnings():
|
||||
if not kwargs.get('verify') and InsecureRequestWarning:
|
||||
if not kwargs.get('verify'):
|
||||
# ignore InsecureRequestWarning if verify=False
|
||||
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
|
||||
yield
|
||||
|
@ -63,7 +63,7 @@ def default_role(docname: str, name: str) -> Generator[None, None, None]:
|
||||
if name:
|
||||
dummy_reporter = Reporter('', 4, 4)
|
||||
role_fn, _ = roles.role(name, english, 0, dummy_reporter)
|
||||
if role_fn:
|
||||
if role_fn: # type: ignore[truthy-function]
|
||||
docutils.register_role('', role_fn)
|
||||
else:
|
||||
logger.warning(__('default role %s not found'), name, location=docname)
|
||||
|
@ -867,7 +867,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
def depart_math(self, node: Element, math_env: str = '') -> None:
|
||||
name = self.builder.math_renderer_name
|
||||
_, depart = self.builder.app.registry.html_inline_math_renderers[name]
|
||||
if depart:
|
||||
if depart: # type: ignore[truthy-function]
|
||||
depart(self, node)
|
||||
|
||||
def visit_math_block(self, node: Element, math_env: str = '') -> None:
|
||||
@ -878,5 +878,5 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
def depart_math_block(self, node: Element, math_env: str = '') -> None:
|
||||
name = self.builder.math_renderer_name
|
||||
_, depart = self.builder.app.registry.html_block_math_renderers[name]
|
||||
if depart:
|
||||
if depart: # type: ignore[truthy-function]
|
||||
depart(self, node)
|
||||
|
@ -805,7 +805,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
def depart_math(self, node: Element, math_env: str = '') -> None:
|
||||
name = self.builder.math_renderer_name
|
||||
_, depart = self.builder.app.registry.html_inline_math_renderers[name]
|
||||
if depart:
|
||||
if depart: # type: ignore[truthy-function]
|
||||
depart(self, node)
|
||||
|
||||
def visit_math_block(self, node: Element, math_env: str = '') -> None:
|
||||
@ -816,5 +816,5 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
def depart_math_block(self, node: Element, math_env: str = '') -> None:
|
||||
name = self.builder.math_renderer_name
|
||||
_, depart = self.builder.app.registry.html_block_math_renderers[name]
|
||||
if depart:
|
||||
if depart: # type: ignore[truthy-function]
|
||||
depart(self, node)
|
||||
|
Loading…
Reference in New Issue
Block a user