Skip to content

Commit

Permalink
Add documentation to pass-statement-stub-body (#7496)
Browse files Browse the repository at this point in the history
## Summary

Add documentation to `pass-statement-stub-body` (`PYI009`) rule. Related
to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
  • Loading branch information
tjkuson committed Sep 18, 2023
1 parent a902d14 commit 0bfdb15
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ use ruff_text_size::Ranged;
use crate::checkers::ast::Checker;
use crate::registry::Rule;

/// ## What it does
/// Checks for `pass` statements in empty stub bodies.
///
/// ## Why is this bad?
/// For consistency, empty stub bodies should contain `...` instead of `pass`.
///
/// Additionally, an ellipsis better conveys the intent of the stub body (that
/// the body has been implemented, but has been intentionally left blank to
/// document the interface).
///
/// ## Example
/// ```python
/// def foo(bar: int) -> list[int]:
/// pass
/// ```
///
/// Use instead:
/// ```python
/// def foo(bar: int) -> list[int]: ...
/// ```
#[violation]
pub struct PassStatementStubBody;

Expand Down

0 comments on commit 0bfdb15

Please sign in to comment.