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

fix: fix PLR1714 lint errors #202

Merged
merged 6 commits into from
Aug 26, 2023
Merged

Conversation

rzhao271
Copy link
Contributor

@rzhao271 rzhao271 commented Jul 29, 2023

% ruff rule PLR1714

repeated-equality-comparison-target (PLR1714)

Derived from the Pylint linter.

What it does

Checks for repeated equality comparisons that can be rewritten as a membership test.

Why is this bad?

To check if a variable is equal to one of many values, it is common to write a series of equality comparisons (e.g., foo == "bar" or foo == "baz").

Instead, prefer to combine the values into a collection and use the in operator to check for membership, which is more performant and succinct.
If the items are hashable, use a set for efficiency; otherwise, use a tuple.

Example

foo == "bar" or foo == "baz" or foo == "qux"

Use instead:

foo in {"bar", "baz", "qux"}

References

@cclauss
Copy link
Contributor

cclauss commented Jul 30, 2023

Please adjust https://github.com/nodejs/gyp-next/blob/main/pyproject.toml#L38 to make these changes permanent.

@cclauss
Copy link
Contributor

cclauss commented Jul 31, 2023

@rzhao271 The ruff rule PLR1714 above makes it simple to make the commit message self-documenting for those who do not have not yet memorized all rules. Especially helpful for project maintainers is the Why is this bad? section.

pyproject.toml Outdated Show resolved Hide resolved
@rzhao271 rzhao271 requested a review from cclauss August 11, 2023 18:29
@rzhao271
Copy link
Contributor Author

@cclauss can the CI be restarted? The integration tests had an issue with finding the tarballs.

@rzhao271 rzhao271 closed this Aug 25, 2023
@rzhao271 rzhao271 reopened this Aug 25, 2023
@cclauss cclauss merged commit f6af11a into nodejs:main Aug 26, 2023
17 checks passed
@rzhao271 rzhao271 deleted the rzhao271/lint-1714 branch August 26, 2023 00:12
@rzhao271 rzhao271 changed the title Fix PLR1714 lint errors fix: fix PLR1714 lint errors Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants