mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 00:20: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
|
@ -63,11 +63,16 @@ pub fn is_abstract(decorator_list: &[Decorator], semantic: &SemanticModel) -> bo
|
|||
/// Returns `true` if a function definition is a `@property`.
|
||||
/// `extra_properties` can be used to check additional non-standard
|
||||
/// `@property`-like decorators.
|
||||
pub fn is_property(
|
||||
pub fn is_property<'a, P, I>(
|
||||
decorator_list: &[Decorator],
|
||||
extra_properties: &[QualifiedName],
|
||||
extra_properties: P,
|
||||
semantic: &SemanticModel,
|
||||
) -> bool {
|
||||
) -> bool
|
||||
where
|
||||
P: IntoIterator<IntoIter = I>,
|
||||
I: Iterator<Item = QualifiedName<'a>> + Clone,
|
||||
{
|
||||
let extra_properties = extra_properties.into_iter();
|
||||
decorator_list.iter().any(|decorator| {
|
||||
semantic
|
||||
.resolve_qualified_name(map_callable(&decorator.expression))
|
||||
|
@ -79,8 +84,8 @@ pub fn is_property(
|
|||
| ["abc", "abstractproperty"]
|
||||
| ["types", "DynamicClassAttribute"]
|
||||
) || extra_properties
|
||||
.iter()
|
||||
.any(|extra_property| extra_property.segments() == qualified_name.segments())
|
||||
.clone()
|
||||
.any(|extra_property| extra_property == qualified_name)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -151,11 +151,11 @@ impl<'a> Definition<'a> {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn is_property(
|
||||
&self,
|
||||
extra_properties: &[QualifiedName],
|
||||
semantic: &SemanticModel,
|
||||
) -> bool {
|
||||
pub fn is_property<P, I>(&self, extra_properties: P, semantic: &SemanticModel) -> bool
|
||||
where
|
||||
P: IntoIterator<IntoIter = I>,
|
||||
I: Iterator<Item = QualifiedName<'a>> + Clone,
|
||||
{
|
||||
self.as_function_def()
|
||||
.is_some_and(|StmtFunctionDef { decorator_list, .. }| {
|
||||
is_property(decorator_list, extra_properties, semantic)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue