diff --git a/bandit/core/config.py b/bandit/core/config.py index 7dbf0a8bb..cdbc8069d 100644 --- a/bandit/core/config.py +++ b/bandit/core/config.py @@ -6,6 +6,11 @@ import yaml +try: + import toml +except ImportError: + toml = None + from bandit.core import constants from bandit.core import extension_loader from bandit.core import utils @@ -36,7 +41,10 @@ def __init__(self, config_file=None): ) if config_file.endswith(".toml"): - import toml + if toml is None: + raise utils.ConfigError( + "toml parser not available, reinstall with toml extra" + ) try: with f: