Skip to content

Commit

Permalink
Accept duplicate entries in INI config files
Browse files Browse the repository at this point in the history
Rationale:
1. The `-D` command line option can be specified multiple times.
   It makes sense to be able to specify the respective config file
   option `dictionary` multiple times too.
2. While spcifying an option multiple times might be an error, the
   setting strict to `True` catches duplicates only within a single
   INI file, not across multiple INI files. If we are serious about
   handling duplicate options, we should therefore handle that
   manually, distinguishing options that can be duplicated or not.
  • Loading branch information
DimitriPapadopoulos committed Feb 23, 2023
1 parent 55fe256 commit c2db608
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def parse_options(
cfg_files = ["setup.cfg", ".codespellrc"]
if options.config:
cfg_files.append(options.config)
config = configparser.ConfigParser(interpolation=None)
config = configparser.ConfigParser(interpolation=None, strict=False)

# Read toml before other config files.
toml_files = []
Expand Down Expand Up @@ -571,7 +571,7 @@ def parse_options(
# Collect which config files are going to be used
used_cfg_files = []
for cfg_file in cfg_files:
_cfg = configparser.ConfigParser()
_cfg = configparser.ConfigParser(interpolation=None, strict=False)
_cfg.read(cfg_file)
if _cfg.has_section("codespell"):
used_cfg_files.append(cfg_file)
Expand Down

0 comments on commit c2db608

Please sign in to comment.