Skip to content

Commit

Permalink
Add documentation to duplicate-union-member (#7225)
Browse files Browse the repository at this point in the history
## Summary

Add documentation to `duplicate-union-member` (`PYI016`) rule. Related
to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
  • Loading branch information
tjkuson authored Sep 12, 2023
1 parent b4419c3 commit e7b7e4a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::comparable::ComparableExpr;
use ruff_text_size::Ranged;

/// ## What it does
/// Checks for duplicate union members.
///
/// ## Why is this bad?
/// Duplicate union members are redundant and should be removed.
///
/// ## Example
/// ```python
/// foo: str | str
/// ```
///
/// Use instead:
/// ```python
/// foo: str
/// ```
///
/// ## References
/// - [Python documentation: `typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union)
#[violation]
pub struct DuplicateUnionMember {
duplicate_name: String,
Expand Down

0 comments on commit e7b7e4a

Please sign in to comment.