Skip to content

Commit

Permalink
[red-knot] Fix some instance-attribute TODOs around ModuleType (#15974
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlexWaygood authored Feb 5, 2025
1 parent 3f958a9 commit c816542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ inside the module:
import typing

reveal_type(typing.__name__) # revealed: str
reveal_type(typing.__init__) # revealed: Literal[__init__]
reveal_type(typing.__init__) # revealed: @Todo(bound method)

# These come from `builtins.object`, not `types.ModuleType`:
reveal_type(typing.__eq__) # revealed: Literal[__eq__]
reveal_type(typing.__eq__) # revealed: @Todo(bound method)

reveal_type(typing.__class__) # revealed: Literal[ModuleType]

Expand Down
7 changes: 2 additions & 5 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ pub(crate) fn global_symbol<'db>(db: &'db dyn Db, file: File, name: &str) -> Sym
.iter()
.any(|module_type_member| &**module_type_member == name)
{
// TODO: this should use `.to_instance(db)`. but we don't understand attribute access
// on instance types yet.
KnownClass::ModuleType.to_class_literal(db).member(db, name)
KnownClass::ModuleType.to_instance(db).member(db, name)
} else {
Symbol::Unbound
}
Expand Down Expand Up @@ -3810,8 +3808,7 @@ impl<'db> ModuleLiteralType<'db> {
if name == "__getattr__" {
Symbol::Unbound
} else {
// TODO: this should use `.to_instance()`, but we don't understand instance attribute yet
KnownClass::ModuleType.to_class_literal(db).member(db, name)
KnownClass::ModuleType.to_instance(db).member(db, name)
}
})
}
Expand Down

0 comments on commit c816542

Please sign in to comment.