Skip to content

Commit

Permalink
Do not allow for a word to start with punctuation symbols
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yarikoptic committed Nov 22, 2024
1 parent 04e9681 commit daa5b9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
__version__ as VERSION, # noqa: N812
)

word_regex_def = r"[\w\-'’]+" # noqa: RUF001
word_regex_def = r"\w[\w\-'’]*" # noqa: RUF001
# While we want to treat characters like ( or " as okay for a starting break,
# these may occur unescaped in URIs, and so we are more restrictive on the
# endpoint. Emails are more restrictive, so the endpoint remains flexible.
Expand Down
3 changes: 2 additions & 1 deletion codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def main(
capsys = frame.f_locals["capsys"]
stdout, stderr = capsys.readouterr()
assert code in (EX_OK, EX_USAGE, EX_DATAERR, EX_CONFIG)
# print(f"stderr: {stderr}")
if code == EX_DATAERR: # have some misspellings
code = int(stderr.split("\n")[-2])
elif code == EX_OK and count:
Expand Down Expand Up @@ -117,7 +118,7 @@ def test_basic(
assert cs.main("--builtin", "clear,rare,names,informal", fname) == 4
with fname.open("w") as f: # overwrite the file
f.write("var = 'nwe must check codespell likes escapes nin strings'\n")
assert cs.main(fname) == 1, "checking our string escape test word is bad"
assert cs.main(fname) == 2, "checking our string escape test word is bad"
# the first one is missed because the apostrophe means its not currently
# treated as a word on its own
with fname.open("w") as f: # overwrite the file
Expand Down

0 comments on commit daa5b9c

Please sign in to comment.