Skip to content

Commit f1de08c

Browse files
authored
[red-knot] Merge the semantic and module-resolver crates (#12751)
1 parent 33e9a6a commit f1de08c

File tree

610 files changed

+91
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

610 files changed

+91
-274
lines changed

.github/workflows/sync_typeshed.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
- name: Sync typeshed
3838
id: sync
3939
run: |
40-
rm -rf ruff/crates/red_knot_module_resolver/vendor/typeshed
41-
mkdir ruff/crates/red_knot_module_resolver/vendor/typeshed
42-
cp typeshed/README.md ruff/crates/red_knot_module_resolver/vendor/typeshed
43-
cp typeshed/LICENSE ruff/crates/red_knot_module_resolver/vendor/typeshed
44-
cp -r typeshed/stdlib ruff/crates/red_knot_module_resolver/vendor/typeshed/stdlib
45-
rm -rf ruff/crates/red_knot_module_resolver/vendor/typeshed/stdlib/@tests
46-
git -C typeshed rev-parse HEAD > ruff/crates/red_knot_module_resolver/vendor/typeshed/source_commit.txt
40+
rm -rf ruff/crates/red_knot_python_semantic/vendor/typeshed
41+
mkdir ruff/crates/red_knot_python_semantic/vendor/typeshed
42+
cp typeshed/README.md ruff/crates/red_knot_python_semantic/vendor/typeshed
43+
cp typeshed/LICENSE ruff/crates/red_knot_python_semantic/vendor/typeshed
44+
cp -r typeshed/stdlib ruff/crates/red_knot_python_semantic/vendor/typeshed/stdlib
45+
rm -rf ruff/crates/red_knot_python_semantic/vendor/typeshed/stdlib/@tests
46+
git -C typeshed rev-parse HEAD > ruff/crates/red_knot_python_semantic/vendor/typeshed/source_commit.txt
4747
- name: Commit the changes
4848
id: commit
4949
if: ${{ steps.sync.outcome == 'success' }}

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ fail_fast: true
22

33
exclude: |
44
(?x)^(
5-
crates/red_knot_module_resolver/vendor/.*|
5+
crates/red_knot_python_semantic/vendor/.*|
6+
crates/red_knot_workspace/resources/.*|
67
crates/ruff_linter/resources/.*|
78
crates/ruff_linter/src/rules/.*/snapshots/.*|
89
crates/ruff/resources/.*|
910
crates/ruff_python_formatter/resources/.*|
1011
crates/ruff_python_formatter/tests/snapshots/.*|
1112
crates/ruff_python_resolver/resources/.*|
12-
crates/ruff_python_resolver/tests/snapshots/.*|
13-
crates/red_knot_workspace/resources/.*
13+
crates/ruff_python_resolver/tests/snapshots/.*
1414
)$
1515
1616
repos:

Cargo.lock

+10-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ ruff_source_file = { path = "crates/ruff_source_file" }
3535
ruff_text_size = { path = "crates/ruff_text_size" }
3636
ruff_workspace = { path = "crates/ruff_workspace" }
3737

38-
red_knot_module_resolver = { path = "crates/red_knot_module_resolver" }
3938
red_knot_python_semantic = { path = "crates/red_knot_python_semantic" }
4039
red_knot_server = { path = "crates/red_knot_server" }
4140
red_knot_workspace = { path = "crates/red_knot_workspace" }

_typos.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[files]
22
# https://github.com/crate-ci/typos/issues/868
3-
extend-exclude = ["crates/red_knot_module_resolver/vendor/**/*", "**/resources/**/*", "**/snapshots/**/*"]
3+
extend-exclude = ["crates/red_knot_python_semantic/vendor/**/*", "**/resources/**/*", "**/snapshots/**/*"]
44

55
[default.extend-words]
66
"arange" = "arange" # e.g. `numpy.arange`

crates/red_knot/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license.workspace = true
1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

1414
[dependencies]
15-
red_knot_module_resolver = { workspace = true }
15+
red_knot_python_semantic = { workspace = true }
1616
red_knot_workspace = { workspace = true }
1717
red_knot_server = { workspace = true }
1818

crates/red_knot/tests/file_watching.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::time::Duration;
66
use anyhow::{anyhow, Context};
77
use salsa::Setter;
88

9-
use red_knot_module_resolver::{resolve_module, ModuleName};
9+
use red_knot_python_semantic::{resolve_module, ModuleName};
1010
use red_knot_workspace::db::RootDatabase;
1111
use red_knot_workspace::watch;
1212
use red_knot_workspace::watch::{directory_watcher, WorkspaceWatcher};

crates/red_knot_module_resolver/Cargo.toml

-39
This file was deleted.

crates/red_knot_module_resolver/src/db.rs

-104
This file was deleted.

crates/red_knot_python_semantic/Cargo.toml

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,34 @@ repository = { workspace = true }
1111
license = { workspace = true }
1212

1313
[dependencies]
14-
red_knot_module_resolver = { workspace = true }
1514
ruff_db = { workspace = true }
1615
ruff_index = { workspace = true }
1716
ruff_python_ast = { workspace = true }
17+
ruff_python_stdlib = { workspace = true }
1818
ruff_text_size = { workspace = true }
1919

2020
bitflags = { workspace = true }
21+
camino = { workspace = true }
22+
compact_str = { workspace = true }
2123
countme = { workspace = true }
24+
once_cell = { workspace = true }
2225
ordermap = { workspace = true }
2326
salsa = { workspace = true }
2427
tracing = { workspace = true }
2528
rustc-hash = { workspace = true }
2629
hashbrown = { workspace = true }
2730

31+
[build-dependencies]
32+
path-slash = { workspace = true }
33+
walkdir = { workspace = true }
34+
zip = { workspace = true, features = ["zstd", "deflate"] }
35+
2836
[dev-dependencies]
2937
anyhow = { workspace = true }
38+
insta = { workspace = true }
39+
tempfile = { workspace = true }
40+
walkdir = { workspace = true }
41+
zip = { workspace = true }
3042
ruff_python_parser = { workspace = true }
3143

3244
[lints]
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Red Knot
22

3-
A work-in-progress multifile module resolver for Ruff.
3+
Semantic analysis for the red-knot project.
44

55
## Vendored types for the stdlib
66

7-
This crate vendors [typeshed](https://github.com/python/typeshed)'s stubs for the standard library. The vendored stubs can be found in `crates/red_knot_module_resolver/vendor/typeshed`. The file `crates/red_knot_module_resolver/vendor/typeshed/source_commit.txt` tells you the typeshed commit that our vendored stdlib stubs currently correspond to.
7+
This crate vendors [typeshed](https://github.com/python/typeshed)'s stubs for the standard library. The vendored stubs can be found in `crates/red_knot_python_semantic/vendor/typeshed`. The file `crates/red_knot_python_semantic/vendor/typeshed/source_commit.txt` tells you the typeshed commit that our vendored stdlib stubs currently correspond to.
88

99
The typeshed stubs are updated every two weeks via an automated PR using the `sync_typeshed.yaml` workflow in the `.github/workflows` directory. This workflow can also be triggered at any time via [workflow dispatch](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow#running-a-workflow).

crates/red_knot_module_resolver/build.rs renamed to crates/red_knot_python_semantic/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//!
44
//! This script should be automatically run at build time
55
//! whenever the script itself changes, or whenever any files
6-
//! in `crates/red_knot_module_resolver/vendor/typeshed` change.
6+
//! in `crates/red_knot_python_semantic/vendor/typeshed` change.
77
88
use std::fs::File;
99
use std::path::Path;

crates/red_knot_python_semantic/src/builtins.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use red_knot_module_resolver::{resolve_module, ModuleName};
2-
1+
use crate::module_name::ModuleName;
2+
use crate::module_resolver::resolve_module;
33
use crate::semantic_index::global_scope;
44
use crate::semantic_index::symbol::ScopeId;
55
use crate::Db;
@@ -11,6 +11,6 @@ use crate::Db;
1111
pub(crate) fn builtins_scope(db: &dyn Db) -> Option<ScopeId<'_>> {
1212
let builtins_name =
1313
ModuleName::new_static("builtins").expect("Expected 'builtins' to be a valid module name");
14-
let builtins_file = resolve_module(db.upcast(), builtins_name)?.file();
14+
let builtins_file = resolve_module(db, builtins_name)?.file();
1515
Some(global_scope(db, builtins_file))
1616
}

0 commit comments

Comments
 (0)