Fix mypy violations

This commit is contained in:
Takeshi KOMIYA 2017-10-07 15:29:29 +09:00
parent 95f0f4d6a0
commit 7d4dab6928
5 changed files with 8 additions and 8 deletions

View File

@ -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 '...'

View File

@ -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

View File

@ -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:

View File

@ -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))

View File

@ -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)