mirror of https://github.com/astral-sh/ruff
Add documentation to `pass-statement-stub-body` (#7496)
## Summary Add documentation to `pass-statement-stub-body` (`PYI009`) rule. Related to #2646. ## Test Plan `python scripts/check_docs_formatted.py`
This commit is contained in:
parent
a902d14c31
commit
0bfdb15ecf
|
|
@ -6,6 +6,26 @@ use ruff_text_size::Ranged;
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
use crate::registry::Rule;
|
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]
|
#[violation]
|
||||||
pub struct PassStatementStubBody;
|
pub struct PassStatementStubBody;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue