mirror of https://github.com/astral-sh/ruff
Add missing docstring sections to the numpy list (#20931)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary Add docstring sections which were missing from the numpy list as pointed out here #20923. For now these are only the official sections as documented [here](https://numpydoc.readthedocs.io/en/latest/format.html#sections). ## Test Plan Added a test case for DOC102
This commit is contained in:
parent
1ade9a5943
commit
64ab79e572
|
|
@ -370,3 +370,22 @@ class Foo:
|
|||
The flag converter instance with all flags parsed.
|
||||
"""
|
||||
return
|
||||
|
||||
# OK
|
||||
def baz(x: int) -> int:
|
||||
"""
|
||||
Show a `Warnings` DOC102 false positive.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
x : int
|
||||
|
||||
Warnings
|
||||
--------
|
||||
This function demonstrates a DOC102 false positive
|
||||
|
||||
Returns
|
||||
-------
|
||||
int
|
||||
"""
|
||||
return x
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ pub(crate) static GOOGLE_SECTIONS: &[SectionKind] = &[
|
|||
SectionKind::References,
|
||||
SectionKind::Returns,
|
||||
SectionKind::SeeAlso,
|
||||
SectionKind::Warnings,
|
||||
SectionKind::Warns,
|
||||
SectionKind::Yields,
|
||||
// Google-only
|
||||
SectionKind::Args,
|
||||
|
|
@ -32,7 +34,5 @@ pub(crate) static GOOGLE_SECTIONS: &[SectionKind] = &[
|
|||
SectionKind::Tip,
|
||||
SectionKind::Todo,
|
||||
SectionKind::Warning,
|
||||
SectionKind::Warnings,
|
||||
SectionKind::Warns,
|
||||
SectionKind::Yield,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ pub(crate) static NUMPY_SECTIONS: &[SectionKind] = &[
|
|||
SectionKind::References,
|
||||
SectionKind::Returns,
|
||||
SectionKind::SeeAlso,
|
||||
SectionKind::Warnings,
|
||||
SectionKind::Warns,
|
||||
SectionKind::Yields,
|
||||
// NumPy-only
|
||||
SectionKind::ExtendedSummary,
|
||||
SectionKind::OtherParams,
|
||||
SectionKind::OtherParameters,
|
||||
SectionKind::Parameters,
|
||||
SectionKind::Receives,
|
||||
SectionKind::ShortSummary,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ pub(crate) enum SectionKind {
|
|||
OtherParameters,
|
||||
Parameters,
|
||||
Raises,
|
||||
Receives,
|
||||
References,
|
||||
Return,
|
||||
Returns,
|
||||
|
|
@ -76,6 +77,7 @@ impl SectionKind {
|
|||
"other parameters" => Some(Self::OtherParameters),
|
||||
"parameters" => Some(Self::Parameters),
|
||||
"raises" => Some(Self::Raises),
|
||||
"receives" => Some(Self::Receives),
|
||||
"references" => Some(Self::References),
|
||||
"return" => Some(Self::Return),
|
||||
"returns" => Some(Self::Returns),
|
||||
|
|
@ -117,6 +119,7 @@ impl SectionKind {
|
|||
Self::OtherParameters => "Other Parameters",
|
||||
Self::Parameters => "Parameters",
|
||||
Self::Raises => "Raises",
|
||||
Self::Receives => "Receives",
|
||||
Self::References => "References",
|
||||
Self::Return => "Return",
|
||||
Self::Returns => "Returns",
|
||||
|
|
|
|||
Loading…
Reference in New Issue