Skip to content

Commit 16e8a33

Browse files
committed
ENH: Do not require prefixes to be into additional dict
Do not require prefixes to be specified in the additional dictionary and perform camel case splitting after removing the prefix Since a given prefix may not have been added to the dictionary, this commit adds an explicit check to verify that the remaining of the word is valid after stripping the prefix.
1 parent f526610 commit 16e8a33

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

codespell.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ def spell_check_comment(
146146
if spell_checker.check(wrd):
147147
valid = True
148148
break
149+
else:
150+
# Try splitting camel case words and checking each sub-words
151+
if output_lvl > 1:
152+
print("Trying splitting camel case word: {wrd}")
153+
sub_words = splitCamelCase(wrd)
154+
if len(sub_words) > 1 and spell_check_words(
155+
spell_checker, sub_words
156+
):
157+
valid = True
158+
break
149159
except BaseException:
150160
print(f"Caught an exception for word {error_word} {wrd}")
151161

tests/example.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//
1313
// Prefix and camel case test word:
1414
// sitkWhiskeyTangoFoxtrot
15+
// myprefixAttributeName
1516
//
1617
// Dictionary test word:
1718
// BinaryFillholeImageFilter

tests/test_codespell.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def test_codespell(self):
2323
"--verbose",
2424
"--dict",
2525
"tests/dict.txt",
26+
"--prefix",
27+
"myprefix",
2628
"tests/example.h",
2729
]
2830
)
@@ -38,6 +40,8 @@ def test_codespell(self):
3840
"python",
3941
"codespell.py",
4042
"--verbose",
43+
"--prefix",
44+
"myprefix",
4145
"--suffix",
4246
".py",
4347
"--suffix",

0 commit comments

Comments
 (0)