-
Notifications
You must be signed in to change notification settings - Fork 497
Closed
Labels
Description
-S SKIP, --skip SKIP comma-separated list of files to skip. It accepts globs as well.
As expected, without --skip
all files gets typos detected
mateusz@grima:~/Desktop/tmp$ codespell
./example file with actual [weird signs in it]:1: speling ==> spelling
./simple:1: speling ==> spelling
./expected:1: speling ==> spelling
Skipping fails for one with [
]
as it gets globbed:
mateusz@grima:~/Desktop/tmp$ codespell --skip "example file with actual [weird signs in it]" --skip simple
./example file with actual [weird signs in it]:1: speling ==> spelling
./expected:1: speling ==> spelling
Yes, it is an actual filename
And yes, it happened with already existing files. It is sadly not some contrived setup.
Workaround
one may use
codespell --skip "example file with actual [weird signs in it]" --skip simple |grep -Fv "example file with actual [weird signs in it]:1: speling ==> spelling"
F
is --fixed-strings PATTERNS are strings
This gives expected
./expected:1: speling ==> spelling
(note that in codespell
both fixes strings and globs may be used in one command)
Bonus crash
Also, as result codespell --skip "example file with actual [weird signs in it and b-a]"
goes down with
Traceback (most recent call last):
File "/home/mateusz/.local/bin/codespell", line 8, in <module>
sys.exit(_script_main())
File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 748, in _script_main
return main(*sys.argv[1:])
File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 876, in main
if glob_match.match(root): # skip (absolute) directories
File "/home/mateusz/.local/lib/python3.8/site-packages/codespell_lib/_codespell.py", line 108, in match
if fnmatch.fnmatch(filename, p):
File "/usr/lib/python3.8/fnmatch.py", line 36, in fnmatch
return fnmatchcase(name, pat)
File "/usr/lib/python3.8/fnmatch.py", line 70, in fnmatchcase
match = _compile_pattern(pat)
File "/usr/lib/python3.8/fnmatch.py", line 46, in _compile_pattern
return re.compile(res).match
File "/usr/lib/python3.8/re.py", line 252, in compile
return _compile(pattern, flags)
File "/usr/lib/python3.8/re.py", line 304, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib/python3.8/sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib/python3.8/sre_parse.py", line 948, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/usr/lib/python3.8/sre_parse.py", line 834, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/usr/lib/python3.8/sre_parse.py", line 598, in _parse
raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range b-a at position 56