mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix mypy violations
This commit is contained in:
parent
d003707f71
commit
f07b080331
@ -65,7 +65,7 @@ def format_annotation(annotation):
|
|||||||
elif (hasattr(typing, 'UnionMeta') and
|
elif (hasattr(typing, 'UnionMeta') and
|
||||||
isinstance(annotation, typing.UnionMeta) and # type: ignore
|
isinstance(annotation, typing.UnionMeta) and # type: ignore
|
||||||
hasattr(annotation, '__union_params__')):
|
hasattr(annotation, '__union_params__')):
|
||||||
params = annotation.__union_params__ # type: ignore
|
params = annotation.__union_params__
|
||||||
if params is not None:
|
if params is not None:
|
||||||
param_str = ', '.join(format_annotation(p) for p in params)
|
param_str = ', '.join(format_annotation(p) for p in params)
|
||||||
return '%s[%s]' % (qualified_name, param_str)
|
return '%s[%s]' % (qualified_name, param_str)
|
||||||
@ -74,7 +74,7 @@ def format_annotation(annotation):
|
|||||||
getattr(annotation, '__args__', None) is not None and
|
getattr(annotation, '__args__', None) is not None and
|
||||||
hasattr(annotation, '__result__')):
|
hasattr(annotation, '__result__')):
|
||||||
# Skipped in the case of plain typing.Callable
|
# Skipped in the case of plain typing.Callable
|
||||||
args = annotation.__args__ # type: ignore
|
args = annotation.__args__
|
||||||
if args is None:
|
if args is None:
|
||||||
return qualified_name
|
return qualified_name
|
||||||
elif args is Ellipsis:
|
elif args is Ellipsis:
|
||||||
@ -84,15 +84,15 @@ def format_annotation(annotation):
|
|||||||
args_str = '[%s]' % ', '.join(formatted_args)
|
args_str = '[%s]' % ', '.join(formatted_args)
|
||||||
return '%s[%s, %s]' % (qualified_name,
|
return '%s[%s, %s]' % (qualified_name,
|
||||||
args_str,
|
args_str,
|
||||||
format_annotation(annotation.__result__)) # type: ignore
|
format_annotation(annotation.__result__))
|
||||||
elif (hasattr(typing, 'TupleMeta') and
|
elif (hasattr(typing, 'TupleMeta') and
|
||||||
isinstance(annotation, typing.TupleMeta) and # type: ignore
|
isinstance(annotation, typing.TupleMeta) and # type: ignore
|
||||||
hasattr(annotation, '__tuple_params__') and
|
hasattr(annotation, '__tuple_params__') and
|
||||||
hasattr(annotation, '__tuple_use_ellipsis__')):
|
hasattr(annotation, '__tuple_use_ellipsis__')):
|
||||||
params = annotation.__tuple_params__ # type: ignore
|
params = annotation.__tuple_params__
|
||||||
if params is not None:
|
if params is not None:
|
||||||
param_strings = [format_annotation(p) for p in params]
|
param_strings = [format_annotation(p) for p in params]
|
||||||
if annotation.__tuple_use_ellipsis__: # type: ignore
|
if annotation.__tuple_use_ellipsis__:
|
||||||
param_strings.append('...')
|
param_strings.append('...')
|
||||||
return '%s[%s]' % (qualified_name,
|
return '%s[%s]' % (qualified_name,
|
||||||
', '.join(param_strings))
|
', '.join(param_strings))
|
||||||
|
@ -434,7 +434,7 @@ class Signature(object):
|
|||||||
elif (hasattr(typing, 'UnionMeta') and # for py35 or below
|
elif (hasattr(typing, 'UnionMeta') and # for py35 or below
|
||||||
isinstance(annotation, typing.UnionMeta) and # type: ignore
|
isinstance(annotation, typing.UnionMeta) and # type: ignore
|
||||||
hasattr(annotation, '__union_params__')):
|
hasattr(annotation, '__union_params__')):
|
||||||
params = annotation.__union_params__ # type: ignore
|
params = annotation.__union_params__
|
||||||
if params is not None:
|
if params is not None:
|
||||||
param_str = ', '.join(self.format_annotation(p) for p in params)
|
param_str = ', '.join(self.format_annotation(p) for p in params)
|
||||||
return '%s[%s]' % (qualified_name, param_str)
|
return '%s[%s]' % (qualified_name, param_str)
|
||||||
@ -442,7 +442,7 @@ class Signature(object):
|
|||||||
getattr(annotation, '__args__', None) is not None and
|
getattr(annotation, '__args__', None) is not None and
|
||||||
hasattr(annotation, '__result__')):
|
hasattr(annotation, '__result__')):
|
||||||
# Skipped in the case of plain typing.Callable
|
# Skipped in the case of plain typing.Callable
|
||||||
args = annotation.__args__ # type: ignore
|
args = annotation.__args__
|
||||||
if args is None:
|
if args is None:
|
||||||
return qualified_name
|
return qualified_name
|
||||||
elif args is Ellipsis:
|
elif args is Ellipsis:
|
||||||
@ -452,14 +452,14 @@ class Signature(object):
|
|||||||
args_str = '[%s]' % ', '.join(formatted_args)
|
args_str = '[%s]' % ', '.join(formatted_args)
|
||||||
return '%s[%s, %s]' % (qualified_name,
|
return '%s[%s, %s]' % (qualified_name,
|
||||||
args_str,
|
args_str,
|
||||||
self.format_annotation(annotation.__result__)) # type: ignore # NOQA
|
self.format_annotation(annotation.__result__))
|
||||||
elif (isinstance(annotation, typing.TupleMeta) and # type: ignore
|
elif (isinstance(annotation, typing.TupleMeta) and # type: ignore
|
||||||
hasattr(annotation, '__tuple_params__') and
|
hasattr(annotation, '__tuple_params__') and
|
||||||
hasattr(annotation, '__tuple_use_ellipsis__')):
|
hasattr(annotation, '__tuple_use_ellipsis__')):
|
||||||
params = annotation.__tuple_params__ # type: ignore
|
params = annotation.__tuple_params__
|
||||||
if params is not None:
|
if params is not None:
|
||||||
param_strings = [self.format_annotation(p) for p in params]
|
param_strings = [self.format_annotation(p) for p in params]
|
||||||
if annotation.__tuple_use_ellipsis__: # type: ignore
|
if annotation.__tuple_use_ellipsis__:
|
||||||
param_strings.append('...')
|
param_strings.append('...')
|
||||||
return '%s[%s]' % (qualified_name,
|
return '%s[%s]' % (qualified_name,
|
||||||
', '.join(param_strings))
|
', '.join(param_strings))
|
||||||
|
Loading…
Reference in New Issue
Block a user