mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
[ty] Do not emit errors if enums or NamedTuples constructed using functional syntax are used in type expressions (#17873)
## Summary This fixes some false positives that showed up in the primer diff for https://github.com/astral-sh/ruff/pull/17832 ## Test Plan new mdtests added that fail with false-positive diagnostics on `main`
This commit is contained in:
parent
fd76d70a31
commit
89424cce5f
2 changed files with 30 additions and 0 deletions
|
@ -4833,6 +4833,17 @@ impl<'db> Type<'db> {
|
|||
Some(KnownClass::UnionType) => Ok(todo_type!(
|
||||
"Support for `types.UnionType` instances in type expressions"
|
||||
)),
|
||||
Some(KnownClass::NamedTuple) => Ok(todo_type!(
|
||||
"Support for functional `typing.NamedTuple` syntax"
|
||||
)),
|
||||
_ if instance
|
||||
.class()
|
||||
.iter_mro(db)
|
||||
.filter_map(ClassBase::into_class)
|
||||
.any(|class| class.is_known(db, KnownClass::Enum)) =>
|
||||
{
|
||||
Ok(todo_type!("Support for functional `enum` syntax"))
|
||||
}
|
||||
_ => Err(InvalidTypeExpressionError {
|
||||
invalid_expressions: smallvec::smallvec![InvalidTypeExpression::InvalidType(
|
||||
*self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue