mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 16:34:46 +00:00
add allow_no_value=True for RawConfigParser
This commit is contained in:
parent
33e1c55853
commit
d3431b5b61
1 changed files with 4 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ from flake8.defaults import VALID_CODE_PREFIX
|
||||||
from flake8.options.manager import OptionManager
|
from flake8.options.manager import OptionManager
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
ALLOW_NO_VALUE = True
|
||||||
|
|
||||||
|
|
||||||
def _stat_key(s: str) -> tuple[int, int]:
|
def _stat_key(s: str) -> tuple[int, int]:
|
||||||
|
|
@ -30,7 +31,7 @@ def _find_config_file(path: str) -> str | None:
|
||||||
dir_stat = _stat_key(path)
|
dir_stat = _stat_key(path)
|
||||||
while True:
|
while True:
|
||||||
for candidate in ("setup.cfg", "tox.ini", ".flake8"):
|
for candidate in ("setup.cfg", "tox.ini", ".flake8"):
|
||||||
cfg = configparser.RawConfigParser()
|
cfg = configparser.RawConfigParser(allow_no_value=ALLOW_NO_VALUE)
|
||||||
cfg_path = os.path.join(path, candidate)
|
cfg_path = os.path.join(path, candidate)
|
||||||
try:
|
try:
|
||||||
cfg.read(cfg_path, encoding="UTF-8")
|
cfg.read(cfg_path, encoding="UTF-8")
|
||||||
|
|
@ -69,12 +70,12 @@ def load_config(
|
||||||
pwd = os.path.abspath(".")
|
pwd = os.path.abspath(".")
|
||||||
|
|
||||||
if isolated:
|
if isolated:
|
||||||
return configparser.RawConfigParser(), pwd
|
return configparser.RawConfigParser(allow_no_value=ALLOW_NO_VALUE), pwd
|
||||||
|
|
||||||
if config is None:
|
if config is None:
|
||||||
config = _find_config_file(pwd)
|
config = _find_config_file(pwd)
|
||||||
|
|
||||||
cfg = configparser.RawConfigParser()
|
cfg = configparser.RawConfigParser(allow_no_value=ALLOW_NO_VALUE)
|
||||||
if config is not None:
|
if config is not None:
|
||||||
if not cfg.read(config, encoding="UTF-8"):
|
if not cfg.read(config, encoding="UTF-8"):
|
||||||
raise exceptions.ExecutionError(
|
raise exceptions.ExecutionError(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue