Skip to content

Commit

Permalink
MAINT: Cleanup conditionals (#2820)
Browse files Browse the repository at this point in the history
  • Loading branch information
marksmayo committed Apr 18, 2023
1 parent 6bb58d6 commit 9e383bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
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

0 comments on commit 9e383bc

Please sign in to comment.