mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 15:48:22 +00:00
Make setting and retrieving pydocstyle settings less tedious (#12582)
This commit is contained in:
parent
138e70bd5c
commit
83b1c48a93
14 changed files with 146 additions and 134 deletions
|
@ -1,14 +1,11 @@
|
|||
use std::collections::BTreeSet;
|
||||
|
||||
use ruff_python_ast::helpers::map_callable;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_semantic::{Definition, SemanticModel};
|
||||
use ruff_source_file::UniversalNewlines;
|
||||
|
||||
use crate::docstrings::sections::{SectionContexts, SectionKind};
|
||||
use crate::docstrings::styles::SectionStyle;
|
||||
use crate::docstrings::Docstring;
|
||||
use crate::rules::pydocstyle::settings::Convention;
|
||||
use crate::rules::pydocstyle::settings::{Convention, Settings};
|
||||
|
||||
/// Return the index of the first logical line in a string.
|
||||
pub(super) fn logical_line(content: &str) -> Option<usize> {
|
||||
|
@ -45,10 +42,12 @@ pub(super) fn ends_with_backslash(line: &str) -> bool {
|
|||
/// Check decorator list to see if function should be ignored.
|
||||
pub(crate) fn should_ignore_definition(
|
||||
definition: &Definition,
|
||||
ignore_decorators: &BTreeSet<String>,
|
||||
settings: &Settings,
|
||||
semantic: &SemanticModel,
|
||||
) -> bool {
|
||||
if ignore_decorators.is_empty() {
|
||||
let ignore_decorators = settings.ignore_decorators();
|
||||
|
||||
if ignore_decorators.len() == 0 {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,15 +60,15 @@ pub(crate) fn should_ignore_definition(
|
|||
.resolve_qualified_name(map_callable(&decorator.expression))
|
||||
.is_some_and(|qualified_name| {
|
||||
ignore_decorators
|
||||
.iter()
|
||||
.any(|decorator| QualifiedName::from_dotted_name(decorator) == qualified_name)
|
||||
.clone()
|
||||
.any(|decorator| decorator == qualified_name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_section_contexts<'a>(
|
||||
docstring: &'a Docstring<'a>,
|
||||
convention: Option<&'a Convention>,
|
||||
convention: Option<Convention>,
|
||||
) -> SectionContexts<'a> {
|
||||
match convention {
|
||||
Some(Convention::Google) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue