Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,40 @@ use crate::fix::snippet::SourceCodeSnippet;
/// ## Example
/// Given:
/// ```python
/// if x > 0:
/// return True
/// else:
/// return False
/// def foo(x: int) -> bool:
/// if x > 0:
/// return True
/// else:
/// return False
/// ```
///
/// Use instead:
/// ```python
/// return x > 0
/// def foo(x: int) -> bool:
/// return x > 0
/// ```
///
/// Or, given:
/// ```python
/// if x > 0:
/// return True
/// return False
/// def foo(x: int) -> bool:
/// if x > 0:
/// return True
/// return False
/// ```
///
/// Use instead:
/// ```python
/// return x > 0
/// def foo(x: int) -> bool:
/// return x > 0
/// ```
///
/// ## Fix safety
///
/// This fix is marked as unsafe because it may change the program’s behavior if the condition does not
/// return a proper Boolean. While the fix will try to wrap non-boolean values in a call to bool,
/// custom implementations of comparison functions like `__eq__` can avoid the bool call and still
/// lead to altered behavior.
///
/// ## References
/// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)
#[derive(ViolationMetadata)]
Expand Down
Loading