Skip to content

Commit e7b7e4a

Browse files
authored
Add documentation to duplicate-union-member (#7225)
## Summary Add documentation to `duplicate-union-member` (`PYI016`) rule. Related to #2646. ## Test Plan `python scripts/check_docs_formatted.py`
1 parent b4419c3 commit e7b7e4a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ use ruff_macros::{derive_message_formats, violation};
1010
use ruff_python_ast::comparable::ComparableExpr;
1111
use ruff_text_size::Ranged;
1212

13+
/// ## What it does
14+
/// Checks for duplicate union members.
15+
///
16+
/// ## Why is this bad?
17+
/// Duplicate union members are redundant and should be removed.
18+
///
19+
/// ## Example
20+
/// ```python
21+
/// foo: str | str
22+
/// ```
23+
///
24+
/// Use instead:
25+
/// ```python
26+
/// foo: str
27+
/// ```
28+
///
29+
/// ## References
30+
/// - [Python documentation: `typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union)
1331
#[violation]
1432
pub struct DuplicateUnionMember {
1533
duplicate_name: String,

0 commit comments

Comments
 (0)