From 7aa94c3291af59268b5936d0628a9775c2295403 Mon Sep 17 00:00:00 2001 From: Alexander OSTROVSKY Date: Mon, 20 Sep 2021 16:46:11 -0700 Subject: [PATCH] re-add assert --- lib/galaxy/datatypes/text.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/datatypes/text.py b/lib/galaxy/datatypes/text.py index b4f04eabdff..46e7f07dd09 100644 --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -880,7 +880,8 @@ class Yaml(Text): if file_prefix.file_size < 50000 and not file_prefix.truncated: # If the file is small enough - don't guess just check. try: - yaml.safe_load(file_prefix.contents_header) + item = yaml.safe_load(file_prefix.contents_header) + assert isinstance(item, (list, dict)) return True except yaml.YAMLError: return False @@ -888,7 +889,8 @@ class Yaml(Text): # If file is too big, load the first part. Trim the current line, in case it cut off in the middle of a key. file_start = file_prefix.string_io().read(50000).strip().rsplit("\n", 1)[0] try: - yaml.safe_load(file_start) + item = yaml.safe_load(file_start) + assert isinstance(item, (list, dict)) return True except yaml.YAMLError: return False