[flake8-pyi] Allow simple assignments to None in enum class scopes (PYI026) (#11128)

This commit is contained in:
Alex Waygood 2024-04-24 15:13:55 +01:00 committed by GitHub
parent 92814fd99b
commit 37af6e6147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 104 additions and 76 deletions

View file

@ -97,3 +97,16 @@ pub fn any_super_class(
inner(class_def, semantic, func, &mut FxHashSet::default())
}
/// Return `true` if `class_def` is a class that has one or more enum classes in its mro
pub fn is_enumeration(class_def: &ast::StmtClassDef, semantic: &SemanticModel) -> bool {
any_qualified_name(class_def, semantic, &|qualified_name| {
matches!(
qualified_name.segments(),
[
"enum",
"Enum" | "Flag" | "IntEnum" | "IntFlag" | "StrEnum" | "ReprEnum" | "CheckEnum"
]
)
})
}