mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Add documentation to non-empty-stub-body
(#7519)
## Summary Add documentation to `non-empty-stub-body` (`PYI010`) rule. Related to #2646. ## Test Plan `python scripts/check_docs_formatted.py`
This commit is contained in:
parent
4ae463d04b
commit
36a60bd50e
2 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,27 @@ 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 non-empty function stub bodies.
|
||||||
|
///
|
||||||
|
/// ## Why is this bad?
|
||||||
|
/// Stub files are meant to be used as a reference for the interface of a
|
||||||
|
/// module, and should not contain any implementation details. Thus, the
|
||||||
|
/// body of a stub function should be empty.
|
||||||
|
///
|
||||||
|
/// ## Example
|
||||||
|
/// ```python
|
||||||
|
/// def double(x: int) -> int:
|
||||||
|
/// return x * 2
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// Use instead:
|
||||||
|
/// ```python
|
||||||
|
/// def double(x: int) -> int: ...
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// ## References
|
||||||
|
/// - [PEP 484 – Type Hints: Stub Files](https://www.python.org/dev/peps/pep-0484/#stub-files)
|
||||||
#[violation]
|
#[violation]
|
||||||
pub struct NonEmptyStubBody;
|
pub struct NonEmptyStubBody;
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ KNOWN_FORMATTING_VIOLATIONS = [
|
||||||
"no-indented-block-comment",
|
"no-indented-block-comment",
|
||||||
"no-space-after-block-comment",
|
"no-space-after-block-comment",
|
||||||
"no-space-after-inline-comment",
|
"no-space-after-inline-comment",
|
||||||
|
"non-empty-stub-body",
|
||||||
"one-blank-line-after-class",
|
"one-blank-line-after-class",
|
||||||
"over-indentation",
|
"over-indentation",
|
||||||
"over-indented",
|
"over-indented",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue