mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[red-knot] don't include Unknown in the type for a conditionally-defined import (#13563)
## Summary Fixes the bug described in #13514 where an unbound public type defaulted to the type or `Unknown`, whereas it should only be the type if unbound. ## Test Plan Added a new test case --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
parent
2095ea8372
commit
ed4a0b34ba
10 changed files with 126 additions and 91 deletions
|
@ -37,6 +37,13 @@ fn core_module_symbol_ty<'db>(
|
|||
) -> Type<'db> {
|
||||
resolve_module(db, &core_module.name())
|
||||
.map(|module| global_symbol_ty(db, module.file(), symbol))
|
||||
.map(|ty| {
|
||||
if ty.is_unbound() {
|
||||
ty
|
||||
} else {
|
||||
ty.replace_unbound_with(db, Type::Never)
|
||||
}
|
||||
})
|
||||
.unwrap_or(Type::Unbound)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue