-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[red-knot] Resolve symbols from
builtins.pyi
in the stdlib if they …
…cannot be found in other scopes (#12390) Co-authored-by: Carl Meyer <[email protected]>
- Loading branch information
1 parent
1c7b840
commit d8cf8ac
Showing
8 changed files
with
231 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use red_knot_module_resolver::{resolve_module, ModuleName}; | ||
|
||
use crate::semantic_index::global_scope; | ||
use crate::semantic_index::symbol::ScopeId; | ||
use crate::Db; | ||
|
||
/// Salsa query to get the builtins scope. | ||
/// | ||
/// Can return None if a custom typeshed is used that is missing `builtins.pyi`. | ||
#[salsa::tracked] | ||
pub(crate) fn builtins_scope(db: &dyn Db) -> Option<ScopeId<'_>> { | ||
let builtins_name = | ||
ModuleName::new_static("builtins").expect("Expected 'builtins' to be a valid module name"); | ||
let builtins_file = resolve_module(db.upcast(), builtins_name)?.file(); | ||
Some(global_scope(db, builtins_file)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters