From 8097fefcbd039b0573ed3a61b65c4b9620da66c6 Mon Sep 17 00:00:00 2001 From: Kieran Ryan Date: Sat, 2 Sep 2023 15:38:06 +0100 Subject: [PATCH] fix(cli): scope config interpolation to radon section --- radon/cli/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/radon/cli/__init__.py b/radon/cli/__init__.py index 3af5138..076adbe 100644 --- a/radon/cli/__init__.py +++ b/radon/cli/__init__.py @@ -78,12 +78,19 @@ def toml_config(): @staticmethod def file_config(): '''Return any file configuration discovered''' - config = configparser.ConfigParser() + config = configparser.RawConfigParser() for path in (os.getenv('RADONCFG', None), 'radon.cfg'): if path is not None and os.path.exists(path): config.read_file(open(path)) config.read_dict(FileConfig.toml_config()) config.read(['setup.cfg', os.path.expanduser('~/.radon.cfg')]) + + if config.has_section(CONFIG_SECTION_NAME): + section = dict(config.items(CONFIG_SECTION_NAME)) + interpolated_config = configparser.ConfigParser() + interpolated_config.read_dict({CONFIG_SECTION_NAME: section}) + config = interpolated_config + return config