Skip to content

Commit

Permalink
fix(cli): scope config interpolation to radon section
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran-ryan committed Sep 2, 2023
1 parent 293ac3f commit 8097fef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion radon/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 8097fef

Please sign in to comment.