Skip to content

Commit

Permalink
Merge pull request #18 from mazulo/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
mazulo authored Oct 18, 2022
2 parents e108263 + 8fc8434 commit 0d5fb1e
Show file tree
Hide file tree
Showing 6 changed files with 649 additions and 24 deletions.
643 changes: 622 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "misspelling"
version = "2.0.6"
version = "2.0.7"
description = "This is a Python library and tool to check for misspelled words in source code."
authors = ["Patrick Mazulo <pmazulo@gmail.com>"]
license = "GNU GENERAL PUBLIC LICENSE"
Expand Down
2 changes: 2 additions & 0 deletions src/misspelling_lib/misspelling_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def check(self, filename: pathlib.Path) -> Tuple[List[Exception], List[List[Unio
with open(filename, "r", encoding="utf-8") as f:
line_ct = 1
for line in f:
if "# ignore-misspelling" in line:
continue
for word in split_words(line):
if word in self._misspelling_dict or word.lower() in self._misspelling_dict:
results.append([filename, line_ct, word])
Expand Down
2 changes: 1 addition & 1 deletion src/misspelling_lib/utils/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def get_version() -> str:
return "2.0.6"
return "2.0.7"
10 changes: 10 additions & 0 deletions tests/test_assets/nine_misspellings_with_ignore.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
yrea [year], # ignore-misspelling
yeras [years],
yersa [years],
yotube [youtube],
youseff [yousef],
youself [yourself],
ytou [you],
yuo [you],
zeebra [zebra],
}
14 changes: 13 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ def test_good_file(self):
assert len(output.decode().split("\n")) == 10
assert p.returncode == 2

def test_good_file_with_ignore_misspelling_comment(self):
p = subprocess.Popen(
[CLI, "test_assets/nine_misspellings_with_ignore.c"],
cwd=TEST_BASE_DIR,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
(output, error_output) = p.communicate()
assert error_output.decode() == ""
assert len(output.decode().split("\n")) == 9
assert p.returncode == 2

def test_bad_file(self):
p = subprocess.Popen(
[CLI, "test_assets/missing.c"],
Expand Down Expand Up @@ -148,7 +160,7 @@ def test_good_flag_s(self):
)
(output, error_output) = p.communicate(input="\n".encode("utf8"))
assert error_output.decode() == ""
assert "withdrawl" in output.decode()
assert "withdrawl" in output.decode() # ignore-misspelling
assert p.returncode == 0

with open(good_out, "r", encoding="utf-8") as good_file:
Expand Down

0 comments on commit 0d5fb1e

Please sign in to comment.