[ty] Don't suggest things that aren't subclasses of BaseException after raise
This only applies to items that have a type associated with them. That is, things that are already in scope. For items that don't have a type associated with them (i.e., suggestions from auto-import), we still suggest them since we can't know if they're appropriate or not. It's not quite clear on how best to improve here for the auto-import case. (Short of, say, asking for the type of each such symbol. But the performance implications of that aren't known yet.) Note that because of auto-import, we were still suggesting `NotImplemented` even though astral-sh/ty#1262 specifically cites it as the motivating example that we *shouldn't* suggest. This was occuring because auto-import was including symbols from the `builtins` module, even though those are actually already in scope. So this PR also gets rid of those suggestions from auto-import. Overall, this means that, at least, `raise NotImpl` won't suggest `NotImplemented`. Fixes astral-sh/ty#1262
This commit is contained in:
committed by
Andrew Gallant
parent
a57e291311
commit
68343e7edf
@@ -1,7 +1,7 @@
|
||||
use std::iter::FusedIterator;
|
||||
|
||||
pub use list::{all_modules, list_modules};
|
||||
pub(crate) use module::KnownModule;
|
||||
pub use module::KnownModule;
|
||||
pub use module::Module;
|
||||
pub use path::{SearchPath, SearchPathValidationError};
|
||||
pub use resolver::SearchPaths;
|
||||
|
||||
@@ -67,7 +67,7 @@ impl<'db> Module<'db> {
|
||||
}
|
||||
|
||||
/// Does this module represent the given known module?
|
||||
pub(crate) fn is_known(self, db: &'db dyn Database, known_module: KnownModule) -> bool {
|
||||
pub fn is_known(self, db: &'db dyn Database, known_module: KnownModule) -> bool {
|
||||
self.known(db) == Some(known_module)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user