Skip to content

Commit

Permalink
Merge pull request #1732 from LeetaoGoooo/main
Browse files Browse the repository at this point in the history
Raise a exception if append-config files does not exist
  • Loading branch information
asottile committed Nov 8, 2022
2 parents ad1006e + 314b9f5 commit c2dc351
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/flake8/options/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def load_config(
# TODO: remove this and replace it with configuration modifying plugins
# read the additional configs afterwards
for filename in extra:
cfg.read(filename, encoding="UTF-8")
if not cfg.read(filename, encoding="UTF-8"):
raise exceptions.ExecutionError(
f"The specified config file does not exist: {filename}"
)

return cfg, cfg_dir

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_options_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def test_load_config_missing_file_raises_exception(capsys):
config.load_config("foo.cfg", [])


def test_load_config_missing_append_config_raise_exception():
with pytest.raises(exceptions.ExecutionError):
config.load_config(None, ["dont_exist_config.cfg"], isolated=False)


def test_invalid_ignore_codes_raise_error(tmpdir, opt_manager):
tmpdir.join("setup.cfg").write("[flake8]\nignore = E203, //comment")
with tmpdir.as_cwd():
Expand Down

0 comments on commit c2dc351

Please sign in to comment.