Skip to content

Commit

Permalink
Merge pull request #306 from sneakers-the-rat/perf-yamllib
Browse files Browse the repository at this point in the history
[perf] Use yamllib if available
  • Loading branch information
cmungall authored Mar 18, 2024
2 parents 90215d2 + 82fcfa6 commit fad7720
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion linkml_runtime/utils/yamlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

YAMLObjTypes = Union[JsonObjTypes, "YAMLRoot"]

try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml.loader import SafeLoader


class YAMLMark(yaml.error.Mark):
def __str__(self):
Expand Down Expand Up @@ -369,7 +374,7 @@ class extended_float(float, TypedNode):
pass


class DupCheckYamlLoader(yaml.loader.SafeLoader):
class DupCheckYamlLoader(SafeLoader):
"""
A YAML loader that throws an error when the same key appears twice
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_issues/test_issue_1040.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def test_issue_1040_file_name(self):
trace. We use this to make sure that the file name gets in correctly. """
with self.assertRaises(yaml.constructor.ConstructorError) as e:
yaml_loader.load(env.input_path('issue_1040.yaml'), SchemaDefinition)
self.assertIn('File "issue_1040.yaml"', str(e.exception))
self.assertIn('"issue_1040.yaml"', str(e.exception))

0 comments on commit fad7720

Please sign in to comment.