Skip to content

Commit

Permalink
Rely on toml conditionally
Browse files Browse the repository at this point in the history
We only want to rely on toml when it's present and tell the user how to
resolve things if in fact they want to use toml

Closes #779
  • Loading branch information
sigmavirus24 committed Jan 27, 2022
1 parent 25fde24 commit 458b4a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bandit/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 458b4a1

Please sign in to comment.