From 22ddf4c8e545ae0d0cf3d909da687f6de261d884 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 7 Oct 2022 14:27:04 +0200 Subject: [PATCH] linter: Use proper Python 3 I/O type for reading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrien Vergé --- yamllint/linter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yamllint/linter.py b/yamllint/linter.py index 58dbba4..a50298a 100644 --- a/yamllint/linter.py +++ b/yamllint/linter.py @@ -14,6 +14,7 @@ # along with this program. If not, see . import re +import io import yaml @@ -227,7 +228,7 @@ def run(input, conf, filepath=None): if isinstance(input, (bytes, str)): return _run(input, conf, filepath) - elif hasattr(input, 'read'): # Python 2's file or Python 3's io.IOBase + elif isinstance(input, io.IOBase): # We need to have everything in memory to parse correctly content = input.read() return _run(content, conf, filepath)