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

Clarify motivation for E713 and E714 #11483

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions crates/ruff_linter/src/rules/pycodestyle/rules/not_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use crate::checkers::ast::Checker;
use crate::registry::Rule;

/// ## What it does
/// Checks for negative comparison using `not {foo} in {bar}`.
/// Checks for membership tests using `not {element} in {collection}`.
///
/// ## Why is this bad?
/// Negative comparison should be done using `not in`.
/// Testing membership with `{element} not in {collection}` is more readable.
///
/// ## Example
/// ```python
Expand Down Expand Up @@ -42,10 +42,11 @@ impl AlwaysFixableViolation for NotInTest {
}

/// ## What it does
/// Checks for negative comparison using `not {foo} is {bar}`.
/// Checks for identity comparisons using `not {foo} is {bar}`.
///
/// ## Why is this bad?
/// Negative comparison should be done using `is not`.
/// According to [PEP8], testing for an object's identity with `is not` is more
/// readable.
///
/// ## Example
/// ```python
Expand All @@ -60,6 +61,8 @@ impl AlwaysFixableViolation for NotInTest {
/// pass
/// Z = X.B is not Y
/// ```
///
/// [PEP8]: https://peps.python.org/pep-0008/#programming-recommendations
#[violation]
pub struct NotIsTest;

Expand Down
Loading