Micha Reiser
a99a45868c
Eagerly validate search paths ( #12783 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-08-12 07:46:59 +00:00
Alex Waygood
37b9bac403
[red-knot] Add support for `--system-site-packages` virtual environments ( #12759 )
2024-08-09 21:02:16 +01:00
Micha Reiser
2abfab0f9b
Move Program and related structs to `red_knot_python_semantic` ( #12777 )
2024-08-09 11:50:45 +02:00
Alex Waygood
d28c5afd14
[red-knot] Remove mentions of Ruff from the CLI help ( #12752 )
...
Co-authored-by: Micha Reiser <micha@reiser.io>
2024-08-08 15:35:10 +01:00
Micha Reiser
2daa914334
Gracefully handle errors in CLI ( #12747 )
2024-08-08 11:02:47 +00:00
Micha Reiser
df7345e118
Exit with an error if there are check failures ( #12735 )
2024-08-08 07:10:18 +00:00
Micha Reiser
dc6aafecc2
Setup tracing and document tracing usage ( #12730 )
2024-08-08 06:28:40 +00:00
Alex Waygood
7fa76a2b2b
[red-knot] Derive `site-packages` from a venv path ( #12716 )
2024-08-06 18:34:37 +00:00
Dhruv Manilawala
14dd6d980e
[red-knot] Keep subcommands optional for the binary ( #12715 )
...
## Summary
This PR updates the `red_knot` CLI to make the subcommand optional.
## Test Plan
Run the following commands:
* `cargo run --bin red_knot --
--current-directory=~/playground/ruff/type_inference` (no subcommand
requirement)
* `cargo run --bin red_knot -- server` (should start the server)
2024-08-06 20:24:49 +05:30
Micha Reiser
846f57fd15
Update salsa ( #12711 )
2024-08-06 13:17:39 +00:00
Micha Reiser
8e6aa78796
Remove 'cli' module from `red_knot` ( #12714 )
2024-08-06 12:10:36 +00:00
Dhruv Manilawala
e91a0fe94a
[red-knot] Implement basic LSP server ( #12624 )
...
## Summary
This PR adds basic LSP implementation for the Red Knot project.
This is basically a fork of the existing `ruff_server` crate into a
`red_knot_server` crate. The following are the main differences:
1. The `Session` stores a map from workspace root to the corresponding
Red Knot database (`RootDatabase`).
2. The database is initialized with the newly implemented `LSPSystem`
(implementation of `System` trait)
3. The `LSPSystem` contains the server index corresponding to each
workspace and an underlying OS system implementation. For certain
methods, the system first checks if there's an open document in LSP
system and returns the information from that. Otherwise, it falls back
to the OS system to get that information. These methods are
`path_metadata`, `read_to_string` and `read_to_notebook`
4. Add `as_any_mut` method for `System`
**Why fork?**
Forking allows us to experiment with the functionalities that are
specific to Red Knot. The architecture is completely different and so
the requirements for an LSP implementation are different as well. For
example, Red Knot only supports a single workspace, so the LSP system
needs to map the multi-workspace support to each Red Knot instance. In
the end, the server code isn't too big, it will be easier to implement
Red Knot specific functionality without worrying about existing server
limitations and it shouldn't be difficult to port the existing server.
## Review
Most of the server files hasn't been changed. I'm going to list down the
files that have been changed along with highlight the specific part of
the file that's changed from the existing server code.
Changed files:
* Red Knot CLI implementation:
https://github.com/astral-sh/ruff/pull/12624/files#diff-579596339a29d3212a641232e674778c339b446de33b890c7fdad905b5eb50e1
* In
https://github.com/astral-sh/ruff/pull/12624/files#diff-b9a9041a8a2bace014bf3687c3ef0512f25e0541f112fad6131b14242f408db6 ,
server capabilities have been updated, dynamic capability registration
is removed
* In
https://github.com/astral-sh/ruff/pull/12624/files#diff-b9a9041a8a2bace014bf3687c3ef0512f25e0541f112fad6131b14242f408db6 ,
the API for `clear_diagnostics` now take in a `Url` instead of
`DocumentQuery` as the document version doesn't matter when clearing
diagnostics after a document is closed
*
[`did_close`](https://github.com/astral-sh/ruff/pull/12624/files#diff-9271370102a6f3be8defaca40c82485b0048731942520b491a3bdd2ee0e25493 ),
[`did_close_notebook`](https://github.com/astral-sh/ruff/pull/12624/files#diff-96fb53ffb12c1694356e17313e4bb37b3f0931e887878b5d7c896c19ff60283b ),
[`did_open`](https://github.com/astral-sh/ruff/pull/12624/files#diff-60e852cf1aa771e993131cabf98eb4c467963a8328f10eccdb43b3e8f0f1fb12 ),
[`did_open_notebook`](https://github.com/astral-sh/ruff/pull/12624/files#diff-ac356eb5e36c3b2c1c135eda9dfbcab5c12574d1cb77c71f7da8dbcfcfb2d2f1 )
are updated to open / close file from the corresponding Red Knot
workspace
* The [diagnostic
handler](https://github.com/astral-sh/ruff/pull/12624/files#diff-4475f318fd0290d0292834569a7df5699debdcc0a453b411b8c3d329f1b879d9 )
is updated to request diagnostics from Red Knot
* The [`Session::new`] method in
https://github.com/astral-sh/ruff/pull/12624/files#diff-55c96201296200c1cab37c8b0407b6c733381374b94be7ae50563bfe95264e4d
is updated to construct the Red Knot databases for each workspace. It
also contains the `index_mut` and `MutIndexGuard` implementation
* And, `LSPSystem` implementation is in
https://github.com/astral-sh/ruff/pull/12624/files#diff-4ed62bd359c43b0bf1a13f04349dcd954966934bb8d544de7813f974182b489e
## Test Plan
First, configure VS Code to use the `red_knot` binary
1. Build the `red_knot` binary by `cargo build`
2. Update the VS Code extension to specify the path to this binary
```json
{
"ruff.path": ["/path/to/ruff/target/debug/red_knot"]
}
```
3. Restart VS Code
Now, open a file containing red-knot specific diagnostics, close the
file and validate that diagnostics disappear.
2024-08-06 11:27:30 +00:00
Alex Waygood
5499821c67
[red-knot] Rename `workspace_root` variables in the module resolver to `src_root` ( #12697 )
...
Fixes #12337
2024-08-05 23:07:18 +01:00
Alex Waygood
fbab04fbe1
[red-knot] Allow multiple `site-packages` search paths ( #12609 )
2024-08-02 13:33:19 +00:00
Dhruv Manilawala
9aa43d5f91
Separate `red_knot` into CLI and `red_knot_workspace` crates ( #12623 )
...
## Summary
This PR separates the current `red_knot` crate into two crates:
1. `red_knot` - This will be similar to the `ruff` crate, it'll act as
the CLI crate
2. `red_knot_workspace` - This includes everything except for the CLI
functionality from the existing `red_knot` crate
Note that the code related to the file watcher is in
`red_knot_workspace` for now but might be required to extract it out in
the future.
The main motivation for this change is so that we can have a `red_knot
server` command. This makes it easier to test the server out without
making any changes in the VS Code extension. All we need is to specify
the `red_knot` executable path in `ruff.path` extension setting.
## Test Plan
- `cargo build`
- `cargo clippy --workspace --all-targets --all-features`
- `cargo shear --fix`
2024-08-02 11:24:36 +00:00
Micha Reiser
e18b4e42d3
[red-knot] Upgrade to the *new* *new* salsa ( #12406 )
2024-07-29 07:21:24 +00:00
Micha Reiser
eac965ecaf
[red-knot] Watch search paths ( #12407 )
2024-07-24 07:38:50 +00:00
Micha Reiser
40d9324f5a
[red-knot] Improved file watching ( #12382 )
2024-07-23 08:18:59 +02:00
Micha Reiser
ad19b3fd0e
[red-knot] Add verbosity argument to CLI ( #12404 )
2024-07-19 11:38:24 +00:00
Micha Reiser
91338ae902
[red-knot] Add basic workspace support ( #12318 )
2024-07-17 11:34:21 +02:00
Alex Waygood
000dabcd88
[red-knot] Allow module-resolution options to be specified via the CLI ( #12246 )
2024-07-09 09:16:28 +00:00
Micha Reiser
b5834d57af
[red-knot] Only store absolute paths in `Files` ( #12215 )
2024-07-09 09:52:13 +02:00
Micha Reiser
ac04380f36
[red-knot] Rename `FileSystem` to `System` ( #12214 )
2024-07-09 07:20:51 +00:00
Alex Waygood
a62a432a48
[red-knot] Respect typeshed's `VERSIONS` file when resolving stdlib modules ( #12141 )
2024-07-05 22:43:31 +00:00
Micha Reiser
4d385b60c8
[red-knot] Migrate CLI to Salsa ( #11972 )
2024-07-04 07:23:45 +00:00
Alex Waygood
93eefb1417
[red-knot] Cleanup module-resolution logic in `module.rs` ( #11777 )
2024-06-06 17:33:02 +01:00
Alex Waygood
303ef02f93
[red-knot] Encapsulate module resolution logic in `module.rs` ( #11767 )
2024-06-06 14:31:09 +00:00
Micha Reiser
4541337f3d
[red-knot] Remove `<Db: SemanticDb>` contraints in favor of dynamic dispatch ( #11339 )
2024-05-08 18:07:14 +02:00
Micha Reiser
1f217d54d0
[red-knot] Remove `Clone` from `Files` ( #11213 )
2024-05-01 09:11:39 +02:00
Micha Reiser
7e28c80354
[red-knot] Refactor `program.check` scheduling ( #11202 )
2024-04-30 07:23:41 +00:00
Micha Reiser
bc03d376e8
[red-knot] Add "cheap" `program.snapshot` ( #11172 )
2024-04-30 07:13:26 +00:00
Micha Reiser
983a06cec3
[red-knot] Resolve and check dependencies ( #11161 )
2024-04-27 15:49:03 +00:00
Micha Reiser
61c97a037c
red-knot: Introduce `program.check` ( #11148 )
2024-04-27 09:01:20 +00:00
Micha Reiser
7cd065e4a2
Kick off Red-knot ( #10849 )
...
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Carl Meyer <carl@astral.sh>
2024-04-27 08:34:00 +00:00