From fafecc97e4b5aabfe1a2e9aa401abda365fc04a8 Mon Sep 17 00:00:00 2001 From: David Peter Date: Fri, 20 Dec 2024 10:18:36 +0100 Subject: [PATCH] Revert possibly-unbound changes --- .../resources/mdtest/import/conditional.md | 2 -- crates/red_knot_python_semantic/src/types.rs | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/red_knot_python_semantic/resources/mdtest/import/conditional.md b/crates/red_knot_python_semantic/resources/mdtest/import/conditional.md index 0adb7ab83a..79686f8e74 100644 --- a/crates/red_knot_python_semantic/resources/mdtest/import/conditional.md +++ b/crates/red_knot_python_semantic/resources/mdtest/import/conditional.md @@ -69,8 +69,6 @@ if coinflip(): ``` ```py -# TODO: We should potentially distinguish between possibly-unbound and possibly-undeclared here: -# error: [possibly-unbound-import] from maybe_undeclared import x reveal_type(x) # revealed: int diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 226174bcb2..7421f23677 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -90,7 +90,12 @@ fn symbol_by_id<'db>(db: &'db dyn Db, scope: ScopeId<'db>, symbol: ScopedSymbolI match inferred { // Symbol is possibly undeclared and definitely unbound - Symbol::Unbound => Symbol::Type(declared_ty, Boundness::PossiblyUnbound), + Symbol::Unbound => { + // TODO: We probably don't want to report `Bound` here. This requires a bit of + // design work though as we might want a different behavior for stubs and for + // normal modules. + Symbol::Type(declared_ty, Boundness::Bound) + } // Symbol is possibly undeclared and (possibly) bound Symbol::Type(inferred_ty, boundness) => Symbol::Type( UnionType::from_elements(db, [inferred_ty, declared_ty].iter().copied()),