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 8e5571f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions radon/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import sys
from contextlib import contextmanager

from mando import Program
try:
# Python 3.11+
Expand Down Expand Up @@ -78,12 +77,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[CONFIG_SECTION_NAME] = section
config = interpolated_config

return config


Expand Down

0 comments on commit 8e5571f

Please sign in to comment.