Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
augustelalande committed Aug 2, 2024
1 parent 8cd1d0a commit 6c1bb0e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl<'a> RaisesSection<'a> {
}
}

#[derive(Debug)]
#[derive(Debug, Default)]
struct DocstringSections<'a> {
returns: Option<GenericSection>,
yields: Option<GenericSection>,
Expand All @@ -364,22 +364,22 @@ struct DocstringSections<'a> {

impl<'a> DocstringSections<'a> {
fn from_sections(sections: &'a SectionContexts, style: SectionStyle) -> Self {
let mut returns: Option<GenericSection> = None;
let mut yields: Option<GenericSection> = None;
let mut raises: Option<RaisesSection> = None;
let mut docstring_sections = Self::default();
for section in sections.iter() {
match section.kind() {
SectionKind::Raises => raises = Some(RaisesSection::from_section(&section, style)),
SectionKind::Returns => returns = Some(GenericSection::from_section(&section)),
SectionKind::Yields => yields = Some(GenericSection::from_section(&section)),
SectionKind::Raises => {
docstring_sections.raises = Some(RaisesSection::from_section(&section, style))
}
SectionKind::Returns => {
docstring_sections.returns = Some(GenericSection::from_section(&section))
}
SectionKind::Yields => {
docstring_sections.yields = Some(GenericSection::from_section(&section))
}
_ => continue,
}
}
Self {
returns,
yields,
raises,
}
docstring_sections
}
}

Expand Down

0 comments on commit 6c1bb0e

Please sign in to comment.