Но после обновления Mypy до последней версии (1.14.1) я получаю ошибку ниже.
error: Argument 1 to "_redirect_stdout" has incompatible type "StringIO"; expected "TextIOWrapper[_WrappedBuffer]" [arg-type]
Пожалуйста, помогите мне понять
- ошибку
- Что изменилось в mypy, что вызывает ошибку, и
- возможные способы ее устранения.
Спасибо!
def _redirect_stdout(
new_target: io.TextIOWrapper
) -> Generator[io.TextIOWrapper, None, None]:
old_target = sys.stdout
sys.stdout = new_target
try:
yield new_target
finally:
sys.stdout = old_target
target_stdout = io.StringIO()
with _redirect_stdout(target_stdout):
print(['These', 'are', 'sample', 'strings.'])
Подробнее здесь: https://stackoverflow.com/questions/793 ... mypy-error
Мобильная версия