Skip to content

fix: fix PLR1714 lint errors - #202

Merged
cclauss merged 6 commits into
nodejs:mainfrom
rzhao271:rzhao271/lint-1714
Aug 26, 2023
Merged

fix: fix PLR1714 lint errors#202
cclauss merged 6 commits into
nodejs:mainfrom
rzhao271:rzhao271/lint-1714

Conversation

@rzhao271

@rzhao271rzhao271 commented Jul 29, 2023

Copy link
Copy Markdown
Contributor

% 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"orfoo=="baz"orfoo=="qux"

Use instead:

fooin {"bar", "baz", "qux"}

References

@cclauss

Copy link
Copy Markdown
Contributor

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

@cclauss

cclauss commented Jul 31, 2023

Copy link
Copy Markdown
Contributor

@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.

Comment threadpyproject.toml Outdated
@rzhao271
rzhao271 requested a review from cclaussAugust 11, 2023 18:29
@rzhao271

Copy link
Copy Markdown
ContributorAuthor

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

@rzhao271rzhao271 reopened this Aug 25, 2023
@cclauss
cclauss merged commit f6af11a into nodejs:mainAug 26, 2023
@rzhao271
rzhao271 deleted the rzhao271/lint-1714 branch August 26, 2023 00:12
@rzhao271rzhao271 mentioned this pull request Aug 26, 2023
@rzhao271rzhao271 changed the title Fix PLR1714 lint errorsfix: fix PLR1714 lint errorsAug 27, 2023
Sign up for freeto 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

@rzhao271@cclauss