Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixes #2820

Merged
merged 2 commits into from Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions codespell_lib/_codespell.py
Expand Up @@ -216,8 +216,7 @@ def init_chardet(self) -> None:
def open(self, filename: str) -> Tuple[List[str], str]:
if self.use_chardet:
return self.open_with_chardet(filename)
else:
return self.open_with_internal(filename)
return self.open_with_internal(filename)

def open_with_chardet(self, filename: str) -> Tuple[List[str], str]:
self.encdetector.reset()
Expand Down Expand Up @@ -672,7 +671,7 @@ def is_text_file(filename: str) -> bool:
def fix_case(word: str, fixword: str) -> str:
if word == word.capitalize():
return ", ".join(w.strip().capitalize() for w in fixword.split(","))
elif word == word.upper():
if word == word.upper():
return fixword.upper()
# they are both lower case
# or we don't have any idea
Expand Down
5 changes: 2 additions & 3 deletions codespell_lib/tests/test_basic.py
Expand Up @@ -50,8 +50,7 @@ def main(
assert code == 0
if std:
return (code, stdout, stderr)
else:
return code
return code


cs = MainWrapper()
Expand Down Expand Up @@ -172,7 +171,7 @@ def test_bad_glob(
assert cs.main("--skip", "[[]b-a[]].txt", g) == 0


@pytest.mark.skipif(not sys.platform == "linux", reason="Only supported on Linux")
@pytest.mark.skipif(sys.platform != "linux", reason="Only supported on Linux")
def test_permission_error(
tmp_path: Path,
capsys: pytest.CaptureFixture[str],
Expand Down
13 changes: 6 additions & 7 deletions codespell_lib/tests/test_dictionary.py
Expand Up @@ -22,12 +22,11 @@
"Cannot run complete tests without aspell when "
"REQUIRE_ASPELL=true. Got error during import:\n{}".format(exp)
)
else:
warnings.warn(
"aspell not found, but not required, skipping aspell tests. Got "
"error during import:\n{}".format(exp),
stacklevel=2,
)
warnings.warn(
"aspell not found, but not required, skipping aspell tests. Got "
"error during import:\n{}".format(exp),
stacklevel=2,
)

global_err_dicts: Dict[str, Dict[str, Any]] = {}
global_pairs: Set[Tuple[str, str]] = set()
Expand Down Expand Up @@ -66,7 +65,7 @@ def test_dictionary_formatting(
try:
_check_err_rep(err, rep, in_aspell, fname, in_dictionary)
except AssertionError as exp:
errors.append(str(exp).split("\n")[0])
errors.append(str(exp).split("\n", maxsplit=1)[0])
if errors:
raise AssertionError("\n" + "\n".join(errors))

Expand Down