Skip to content

Commit ec38cc5

Browse files
committed
enh: print considered config files
1 parent 8236d11 commit ec38cc5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

codespell_lib/_codespell.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,21 @@ def parse_options(args):
423423
with open(toml_file, 'rb') as f:
424424
data = tomli.load(f).get('tool', {})
425425
config.read_dict(data)
426-
config.read(cfg_files)
427426

427+
# Report which config files are going to be used
428+
used_cfg_files = []
429+
for cfg_file in cfg_files:
430+
_cfg = configparser.ConfigParser()
431+
_cfg.read(cfg_file)
432+
if _cfg.has_section('codespell'):
433+
used_cfg_files.append(cfg_file)
434+
if len(used_cfg_files) > 0:
435+
print('Used config files:\n')
436+
for ifile, cfg_file in enumerate(used_cfg_files):
437+
print(' %i : %s' % (ifile, cfg_file))
438+
439+
# Use config files
440+
config.read(cfg_files)
428441
if config.has_section('codespell'):
429442
# Build a "fake" argv list using option name and value.
430443
cfg_args = []

0 commit comments

Comments
 (0)