mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[red-knot] Reduce false positives on super()
and enum-class attribute accesses (#17004)
## Summary This PR adds some branches so that we infer `Todo` types for attribute access on instances of `super()` and subtypes of `type[Enum]`. It reduces false positives in the short term until we implement full support for these features. ## Test Plan New mdtests added + mypy_primer report
This commit is contained in:
parent
c963b185eb
commit
992a1af4c2
5 changed files with 63 additions and 1 deletions
|
@ -104,6 +104,7 @@ impl ModuleKind {
|
|||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum KnownModule {
|
||||
Builtins,
|
||||
Enum,
|
||||
Types,
|
||||
#[strum(serialize = "_typeshed")]
|
||||
Typeshed,
|
||||
|
@ -121,6 +122,7 @@ impl KnownModule {
|
|||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::Builtins => "builtins",
|
||||
Self::Enum => "enum",
|
||||
Self::Types => "types",
|
||||
Self::Typing => "typing",
|
||||
Self::Typeshed => "_typeshed",
|
||||
|
@ -164,6 +166,10 @@ impl KnownModule {
|
|||
pub const fn is_inspect(self) -> bool {
|
||||
matches!(self, Self::Inspect)
|
||||
}
|
||||
|
||||
pub const fn is_enum(self) -> bool {
|
||||
matches!(self, Self::Enum)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for KnownModule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue