Fix mypy violations (with mypy-0.930)

This commit is contained in:
Takeshi KOMIYA
2021-12-24 00:15:11 +09:00
parent 94acb1921c
commit 565152301f
4 changed files with 9 additions and 9 deletions

View File

@@ -44,7 +44,7 @@ extras_require = {
'lint': [
'flake8>=3.5.0',
'isort',
'mypy>=0.920',
'mypy>=0.930',
'docutils-stubs',
"types-typed-ast",
"types-pkg_resources",

View File

@@ -621,7 +621,7 @@ class BuildEnvironment:
def check_consistency(self) -> None:
"""Do consistency checks."""
included = set().union(*self.included.values()) # type: ignore
included = set().union(*self.included.values())
for docname in sorted(self.all_docs):
if docname not in self.files_to_rebuild:
if docname == self.config.root_doc:

View File

@@ -134,7 +134,7 @@ def unwrap_all(obj: Any, *, stop: Callable = None) -> Any:
elif ispartial(obj):
obj = obj.func
elif inspect.isroutine(obj) and hasattr(obj, '__wrapped__'):
obj = obj.__wrapped__
obj = obj.__wrapped__ # type: ignore
elif isclassmethod(obj):
obj = obj.__func__
elif isstaticmethod(obj):
@@ -692,7 +692,7 @@ def signature(subject: Callable, bound_method: bool = False, follow_wrapped: boo
#
# For example, this helps a function having a default value `inspect._empty`.
# refs: https://github.com/sphinx-doc/sphinx/issues/7935
return inspect.Signature(parameters, return_annotation=return_annotation, # type: ignore
return inspect.Signature(parameters, return_annotation=return_annotation,
__validate_parameters__=False)
@@ -820,14 +820,14 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
positionals = len(args.args)
for _ in range(len(defaults), positionals):
defaults.insert(0, Parameter.empty)
defaults.insert(0, Parameter.empty) # type: ignore
if hasattr(args, "posonlyargs"):
for i, arg in enumerate(args.posonlyargs): # type: ignore
if defaults[i] is Parameter.empty:
default = Parameter.empty
else:
default = DefaultValue(ast_unparse(defaults[i], code))
default = DefaultValue(ast_unparse(defaults[i], code)) # type: ignore
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
params.append(Parameter(arg.arg, Parameter.POSITIONAL_ONLY,
@@ -837,7 +837,7 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
if defaults[i + posonlyargs] is Parameter.empty:
default = Parameter.empty
else:
default = DefaultValue(ast_unparse(defaults[i + posonlyargs], code))
default = DefaultValue(ast_unparse(defaults[i + posonlyargs], code)) # type: ignore # NOQA
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
params.append(Parameter(arg.arg, Parameter.POSITIONAL_OR_KEYWORD,
@@ -849,7 +849,7 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
annotation=annotation))
for i, arg in enumerate(args.kwonlyargs):
default = ast_unparse(args.kw_defaults[i], code) or Parameter.empty
default = ast_unparse(args.kw_defaults[i], code) or Parameter.empty # type: ignore
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
params.append(Parameter(arg.arg, Parameter.KEYWORD_ONLY, default=default,
annotation=annotation))

View File

@@ -107,7 +107,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
# Overwrite admonition label translations with our own
for label, translation in admonitionlabels.items():
self.language.labels[label] = self.deunicode(translation) # type: ignore
self.language.labels[label] = self.deunicode(translation)
# overwritten -- added quotes around all .TH arguments
def header(self) -> str: