Skip to content

Commit daa5b9c

Browse files
committed
Do not allow for a word to start with punctuation symbols
The inspired for me to look use case - https://github.com/INTERSECT-SDK/python-sdk/pull/19/files/33da9ff31d6162caa0dfc1a1155f321e6d68b1cc#diff-10380fd6e5ecb84c1ae11e135982739946c5aff1a50499378db397cf5034f54e And then I found the issue this - Close codespell-project#3305 Although may be I am missing the use-cases/problems @DimitriPapadopoulos and @mdeweerd discussed back then
1 parent 04e9681 commit daa5b9c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

codespell_lib/_codespell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
__version__ as VERSION, # noqa: N812
5454
)
5555

56-
word_regex_def = r"[\w\-'’]+" # noqa: RUF001
56+
word_regex_def = r"\w[\w\-'’]*" # noqa: RUF001
5757
# While we want to treat characters like ( or " as okay for a starting break,
5858
# these may occur unescaped in URIs, and so we are more restrictive on the
5959
# endpoint. Emails are more restrictive, so the endpoint remains flexible.

codespell_lib/tests/test_basic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def main(
5151
capsys = frame.f_locals["capsys"]
5252
stdout, stderr = capsys.readouterr()
5353
assert code in (EX_OK, EX_USAGE, EX_DATAERR, EX_CONFIG)
54+
# print(f"stderr: {stderr}")
5455
if code == EX_DATAERR: # have some misspellings
5556
code = int(stderr.split("\n")[-2])
5657
elif code == EX_OK and count:
@@ -117,7 +118,7 @@ def test_basic(
117118
assert cs.main("--builtin", "clear,rare,names,informal", fname) == 4
118119
with fname.open("w") as f: # overwrite the file
119120
f.write("var = 'nwe must check codespell likes escapes nin strings'\n")
120-
assert cs.main(fname) == 1, "checking our string escape test word is bad"
121+
assert cs.main(fname) == 2, "checking our string escape test word is bad"
121122
# the first one is missed because the apostrophe means its not currently
122123
# treated as a word on its own
123124
with fname.open("w") as f: # overwrite the file

0 commit comments

Comments
 (0)