mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
[ty] Make Module
a Salsa ingredient
We want to write queries that depend on `Module` for caching. While it seems it can be done without making `Module` an ingredient, it seems it is best practice to do so. [best practice to do so]: https://github.com/astral-sh/ruff/pull/19408#discussion_r2215867301
This commit is contained in:
parent
905b9d7f51
commit
4573a0f6a0
24 changed files with 258 additions and 253 deletions
|
@ -374,7 +374,7 @@ pub(crate) fn imported_symbol<'db>(
|
|||
pub(crate) fn builtins_symbol<'db>(db: &'db dyn Db, symbol: &str) -> PlaceAndQualifiers<'db> {
|
||||
resolve_module(db, &KnownModule::Builtins.name())
|
||||
.and_then(|module| {
|
||||
let file = module.file()?;
|
||||
let file = module.file(db)?;
|
||||
Some(
|
||||
symbol_impl(
|
||||
db,
|
||||
|
@ -404,7 +404,7 @@ pub(crate) fn known_module_symbol<'db>(
|
|||
) -> PlaceAndQualifiers<'db> {
|
||||
resolve_module(db, &known_module.name())
|
||||
.and_then(|module| {
|
||||
let file = module.file()?;
|
||||
let file = module.file(db)?;
|
||||
Some(imported_symbol(db, file, symbol, None))
|
||||
})
|
||||
.unwrap_or_default()
|
||||
|
@ -442,7 +442,7 @@ pub(crate) fn builtins_module_scope(db: &dyn Db) -> Option<ScopeId<'_>> {
|
|||
/// Can return `None` if a custom typeshed is used that is missing the core module in question.
|
||||
fn core_module_scope(db: &dyn Db, core_module: KnownModule) -> Option<ScopeId<'_>> {
|
||||
let module = resolve_module(db, &core_module.name())?;
|
||||
Some(global_scope(db, module.file()?))
|
||||
Some(global_scope(db, module.file(db)?))
|
||||
}
|
||||
|
||||
/// Infer the combined type from an iterator of bindings, and return it
|
||||
|
@ -812,7 +812,7 @@ fn symbol_impl<'db>(
|
|||
|
||||
if name == "platform"
|
||||
&& file_to_module(db, scope.file(db))
|
||||
.is_some_and(|module| module.is_known(KnownModule::Sys))
|
||||
.is_some_and(|module| module.is_known(db, KnownModule::Sys))
|
||||
{
|
||||
match Program::get(db).python_platform(db) {
|
||||
crate::PythonPlatform::Identifier(platform) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue