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
95f0f4d6a0
commit
7d4dab6928
@ -368,7 +368,7 @@ def format_annotation(annotation):
|
||||
|
||||
Displaying complex types from ``typing`` relies on its private API.
|
||||
"""
|
||||
if typing and isinstance(annotation, typing.TypeVar): # type: ignore
|
||||
if typing and isinstance(annotation, typing.TypeVar):
|
||||
return annotation.__name__
|
||||
if annotation == Ellipsis:
|
||||
return '...'
|
||||
|
@ -534,7 +534,7 @@ def valid_dir(d):
|
||||
if not path.isdir(dir):
|
||||
return False
|
||||
|
||||
if set(['Makefile', 'make.bat']) & set(os.listdir(dir)):
|
||||
if set(['Makefile', 'make.bat']) & set(os.listdir(dir)): # type: ignore
|
||||
return False
|
||||
|
||||
if d['sep']:
|
||||
@ -550,7 +550,7 @@ def valid_dir(d):
|
||||
d['dot'] + 'templates',
|
||||
d['master'] + d['suffix'],
|
||||
]
|
||||
if set(reserved_names) & set(os.listdir(dir)):
|
||||
if set(reserved_names) & set(os.listdir(dir)): # type: ignore
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -136,13 +136,13 @@ class NewLineStreamHandlerPY2(logging.StreamHandler):
|
||||
# type: (logging.LogRecord) -> None
|
||||
try:
|
||||
self.acquire()
|
||||
stream = self.stream # type: ignore
|
||||
stream = self.stream
|
||||
if getattr(record, 'nonl', False):
|
||||
# remove return code forcely when nonl=True
|
||||
self.stream = StringIO()
|
||||
super(NewLineStreamHandlerPY2, self).emit(record)
|
||||
stream.write(self.stream.getvalue()[:-1])
|
||||
stream.flush()
|
||||
stream.write(self.stream.getvalue()[:-1]) # type: ignore
|
||||
stream.flush() # type: ignore
|
||||
else:
|
||||
super(NewLineStreamHandlerPY2, self).emit(record)
|
||||
finally:
|
||||
|
@ -96,7 +96,7 @@ _pat_cache = {} # type: Dict[unicode, Pattern]
|
||||
|
||||
|
||||
def patmatch(name, pat):
|
||||
# type: (unicode, unicode) -> re.Match
|
||||
# type: (unicode, unicode) -> Match[unicode]
|
||||
"""Return if name matches pat. Adapted from fnmatch module."""
|
||||
if pat not in _pat_cache:
|
||||
_pat_cache[pat] = re.compile(_translate_pattern(pat))
|
||||
|
@ -36,7 +36,7 @@ if PY3:
|
||||
from io import TextIOWrapper
|
||||
else:
|
||||
def TextIOWrapper(stream, encoding):
|
||||
# type: (file, str) -> unicode
|
||||
# type: (file, str) -> Any
|
||||
return codecs.lookup(encoding or 'ascii')[2](stream)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user