mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-16 00:59:52 +00:00
add check for a missing specified config file
This commit is contained in:
parent
d478d92299
commit
d948169292
2 changed files with 6 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
|
from flake8 import exceptions
|
||||||
from flake8.options.manager import OptionManager
|
from flake8.options.manager import OptionManager
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
@ -60,7 +61,10 @@ def load_config(
|
||||||
|
|
||||||
cfg = configparser.RawConfigParser()
|
cfg = configparser.RawConfigParser()
|
||||||
if config is not None:
|
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)
|
cfg_dir = os.path.dirname(config)
|
||||||
else:
|
else:
|
||||||
cfg_dir = pwd
|
cfg_dir = pwd
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ def test_config_file_not_found(tmpdir, capsys):
|
||||||
|
|
||||||
expected = """\
|
expected = """\
|
||||||
There was a critical error during execution of Flake8:
|
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():
|
with tmpdir.as_cwd():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue