-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple dictionaries (add default one) for dictionary
config setting
#2727
Comments
Let's start with command line options, we'll look into configuration files later. The output of
I would expect If it does work, chances are this works in the configuration file:
|
Thank you @DimitriPapadopoulos for the rapid follow up -- sorry I missed it . -D- -D .codespell_dict -- works!❯ codespell -D- -D .codespell_dict
./README.md:63: folders ==> directories
./README.md:64: sub-directory ==> subdirectory
./README.md:65: zumba ==> zebra
./DECISION-MAKING.md:17: Curent ==> Current
./src/common-principles.md:188: entites ==> entities
❯ codespell -D-
./DECISION-MAKING.md:17: Curent ==> Current
./src/common-principles.md:188: entites ==> entities
❯ cat .codespell_dict
sub-directory->subdirectory
sub-directories->subdirectories
file name->filename
file names->filenames
folder->directory
folders->directories
zumba->zebra
Two lines in config file -- does not!❯ grep dictionary .codespellrc
dictionary = -
dictionary = .codespell_dict
changes on filesystem:
.codespellrc | 1 +
❯ codespell --version
2.2.2
changes on filesystem:
.codespellrc | 1 +
❯ codespell
Traceback (most recent call last):
File "/usr/bin/codespell", line 33, in <module>
sys.exit(load_entry_point('codespell==0.0.0', 'console_scripts', 'codespell')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/codespell_lib/_codespell.py", line 767, in _script_main
return main(*sys.argv[1:])
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/codespell_lib/_codespell.py", line 772, in main
options, parser = parse_options(args)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/codespell_lib/_codespell.py", line 427, in parse_options
config.read(cfg_files)
File "/usr/lib/python3.11/configparser.py", line 712, in read
self._read(fp, filename)
File "/usr/lib/python3.11/configparser.py", line 1111, in _read
raise DuplicateOptionError(sectname, optname,
configparser.DuplicateOptionError: While reading from '.codespellrc' [line 6]: option 'dictionary' in section 'codespell' already exists
|
While
Since this is not a new application, I shall propose to set strict to We can think about adding support for multiple dictionaries separated by |
no good. With the patch adding strict=Falsediff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
index a082e6d1..8f975179 100644
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -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 = []
@@ -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(strict=False)
_cfg.read(cfg_file)
if _cfg.has_section("codespell"):
used_cfg_files.append(cfg_file)
it no longer crashes but it just takes the 2nd value as the value, not a list of values (ie dictionaries). |
Right, configparser.ConfigParser.read_file does not raise a I need to dig in |
@larsoner I see multiple issues in codespell options:
Solutions:
We could do both, of course. Thoughts? |
I prefer solution (2) to (1) |
Solution 2 is being implemented in #2767. |
we have
in https://github.com/bids-standard/bids-specification/blob/HEAD/.codespellrc but that disables default dictionaries, and I need to specify
-D-
to get them used:Unfortunately,
-D
is the different style than e.g.--skip
which expects them comma separated and-D
doesn't work that way:so the question is how could I keep using default dictionaries + custom one while relying on specification in the config file?
The text was updated successfully, but these errors were encountered: