mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
parent
1e0642fac8
commit
104608b2f7
1 changed files with 17 additions and 1 deletions
|
@ -32,7 +32,7 @@ impl EqCmpOp {
|
|||
///
|
||||
/// ## Why is this bad?
|
||||
/// According to [PEP 8], "Comparisons to singletons like None should always be done with
|
||||
/// is or is not, never the equality operators."
|
||||
/// `is` or `is not`, never the equality operators."
|
||||
///
|
||||
/// ## Example
|
||||
/// ```python
|
||||
|
@ -48,7 +48,15 @@ impl EqCmpOp {
|
|||
/// pass
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This rule's fix is marked as unsafe, as it may alter runtime behavior when
|
||||
/// used with libraries that override the `==`/`__eq__` or `!=`/`__ne__` operators.
|
||||
/// In these cases, `is`/`is not` may not be equivalent to `==`/`!=`. For more
|
||||
/// information, see [this issue].
|
||||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#programming-recommendations
|
||||
/// [this issue]: https://github.com/astral-sh/ruff/issues/4560
|
||||
#[violation]
|
||||
pub struct NoneComparison(EqCmpOp);
|
||||
|
||||
|
@ -101,7 +109,15 @@ impl AlwaysFixableViolation for NoneComparison {
|
|||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This rule's fix is marked as unsafe, as it may alter runtime behavior when
|
||||
/// used with libraries that override the `==`/`__eq__` or `!=`/`__ne__` operators.
|
||||
/// In these cases, `is`/`is not` may not be equivalent to `==`/`!=`. For more
|
||||
/// information, see [this issue].
|
||||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#programming-recommendations
|
||||
/// [this issue]: https://github.com/astral-sh/ruff/issues/4560
|
||||
#[violation]
|
||||
pub struct TrueFalseComparison {
|
||||
value: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue