From c8d6a7f44f1ff6a0fca1130929a8a1eef97219e5 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 21 Mar 2024 14:50:51 +0100 Subject: [PATCH] Faster yaml loading using the native loader if available --- pyproject.toml | 1 + src/taskgraph/util/yaml.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2b5d77a0..67e53077 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,5 +58,6 @@ exclude = [ # TODO fix errors in these files "src/taskgraph/util/taskcluster.py", "src/taskgraph/util/vcs.py", "src/taskgraph/util/workertypes.py", + "src/taskgraph/util/yaml.py", ] reportIncompatibleMethodOverride = false diff --git a/src/taskgraph/util/yaml.py b/src/taskgraph/util/yaml.py index 141c7a16..31f05fee 100644 --- a/src/taskgraph/util/yaml.py +++ b/src/taskgraph/util/yaml.py @@ -4,8 +4,12 @@ import os +import typing -from yaml.loader import SafeLoader +try: + from yaml import CSafeLoader as SafeLoader +except ImportError: + from yaml import SafeLoader class UnicodeLoader(SafeLoader):