diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index d7519df..7cba936 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -8,6 +8,7 @@ from typing import List from typing import Optional from typing import Tuple +from flake8 import exceptions from flake8.options.manager import OptionManager LOG = logging.getLogger(__name__) @@ -60,7 +61,10 @@ def load_config( cfg = configparser.RawConfigParser() if config is not None: - cfg.read(config) + if not cfg.read(config): + raise exceptions.ExecutionError( + f"The specified config file does not exist: {config}" + ) cfg_dir = os.path.dirname(config) else: cfg_dir = pwd diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index 90877d3..fe254b7 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -394,7 +394,7 @@ def test_config_file_not_found(tmpdir, capsys): expected = """\ There was a critical error during execution of Flake8: -The specified config file does not exist +The specified config file does not exist: missing.cfg """ with tmpdir.as_cwd():