Skip to content

Commit

Permalink
Add known problems warning to type-comparison rule (#12769)
Browse files Browse the repository at this point in the history
## Summary

See: #4560
  • Loading branch information
charliermarsh authored Aug 9, 2024
1 parent bc5b9b8 commit c906b01
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/ruff_linter/src/rules/pycodestyle/rules/type_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ use crate::checkers::ast::Checker;
///
/// If you want to check for an exact type match, use `is` or `is not`.
///
/// ## Known problems
/// When using libraries that override the `==` (`__eq__`) operator (such as NumPy,
/// Pandas, and SQLAlchemy), this rule may produce false positives, as converting
/// from `==` to `is` or `is not` will change the behavior of the code.
///
/// For example, the following operations are _not_ equivalent:
/// ```python
/// import numpy as np
///
/// np.array([True, False]) == False
/// # array([False, True])
///
/// np.array([True, False]) is False
/// # False
/// ```
///
/// ## Example
/// ```python
/// if type(obj) == type(1):
Expand Down

0 comments on commit c906b01

Please sign in to comment.