Skip to content

Commit

Permalink
Fix new ruff errors
Browse files Browse the repository at this point in the history
PLC1901 `val != ""` can be simplified to `not val` as an empty string is falsey
PLC1901 `stderr == ""` can be simplified to `stderr` as an empty string is falsey
PLC1901 `stdout == ""` can be simplified to `stdout` as an empty string is falsey

The rule is broken and suggests incorrect fixes, see:
	astral-sh/ruff#3503

However, while the suggested fixes are incorrect, the intent is correct.
  • Loading branch information
DimitriPapadopoulos committed Mar 14, 2023
1 parent eef3be1 commit 5913625
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def parse_options(
cfg_args.append(f"--{key}")
# If value is blank, skip.
val = config["codespell"][key]
if val != "":
if val:
cfg_args.append(val)

# Parse config file options.
Expand Down
8 changes: 4 additions & 4 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_basic(
assert isinstance(result, tuple)
code, stdout, stderr = result
assert code == 0
assert stdout == stderr == ""
assert not stdout and not stderr
assert cs.main(tmp_path) == 0

# empty directory
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_summary(
assert isinstance(result, tuple)
code, stdout, stderr = result
assert code == 0
assert stdout == stderr == "", "no output"
assert not stdout and not stderr, "no output"
result = cs.main(fname, "--summary", std=True)
assert isinstance(result, tuple)
code, stdout, stderr = result
Expand Down Expand Up @@ -375,12 +375,12 @@ def test_encoding(
assert isinstance(result, tuple)
code, stdout, stderr = result
assert code == 0
assert stdout == stderr == ""
assert not stdout and not stderr
result = cs.main("-q", "0", fname, std=True, count=False)
assert isinstance(result, tuple)
code, stdout, stderr = result
assert code == 0
assert stdout == ""
assert not stdout
assert "WARNING: Binary file" in stderr


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-re
extend-ignore = [
"ANN101",
"B904",
"PLC1901",
"PLW2901",
]
line-length = 88
Expand Down

0 comments on commit 5913625

Please sign in to comment.