diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index d9e43dfc..8ce3433d 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -31,7 +31,6 @@ from dataclasses import asdict, dataclass import yaml import pydantic -import ruamel.yaml import yaml.parser import capa.perf @@ -1053,6 +1052,11 @@ class Rule: @staticmethod def _get_ruamel_yaml_parser(): + # we use lazy importing here to avoid eagerly loading dependencies + # that some specialized environments may not have, + # e.g., those that run capa without ruamel. + import ruamel.yaml + # use ruamel to enable nice formatting # we use the ruamel.yaml parser because it supports roundtripping of documents with comments.