xlcnd / isbnlib

python library to validate, clean, transform and get metadata of ISBN strings (for devs).
Other
229 stars 30 forks source link

Undo double negation #139

Closed cclauss closed 1 year ago

cclauss commented 1 year ago

IMPORTANT

Make your pull request against the dev branch, please!

% ruff --select=SIM202 .

  2 SIM202  [*] Use `check_digit10(isbn10[:-1]) == isbn10[-1]` instead of `not check_digit10(isbn10[:-1]) != isbn10[-1]`

% ruff --select=SIM202 --fix .

Found 2 errors (2 fixed, 0 remaining).

% ruff rule SIM202

negate-not-equal-op (SIM202)

Derived from the flake8-simplify linter.

Autofix is always available.

What it does

Checks for negated != operators.

Why is this bad?

Negated != operators are less readable than == operators, as they avoid a double negation.

Example

not a != b

Use instead:

a == b

References

@xlcnd