Dhruv Manilawala
221ea662e0
Bump version to 0.5.7 ( #12756 )
2024-08-08 20:56:15 +05:30
Alex Waygood
f1de08c2a0
[red-knot] Merge the semantic and module-resolver crates ( #12751 )
2024-08-08 15:34:11 +01: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
Micha Reiser
846f57fd15
Update salsa ( #12711 )
2024-08-06 13:17:39 +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
Micha Reiser
d2c627efb3
Use standard allocator for wasm ( #12713 )
2024-08-06 11:20:47 +00:00
Micha Reiser
10e977d5f5
[red-knot] Add basic WASM API ( #12654 )
2024-08-06 09:21:42 +02:00
Micha Reiser
ff2aa3ea00
Revert "Remove criterion/codspeed compat layer ( #12524 )" ( #12680 )
2024-08-05 07:49:04 +00:00
Micha Reiser
756060d676
Upgrade Salsa to a version with a 32bit compatible concurrent vec ( #12679 )
2024-08-05 08:50:32 +02:00
renovate[bot]
2c79045342
Update Rust crate pep440_rs to v0.6.6 ( #12666 )
2024-08-04 22:42:43 -04:00
renovate[bot]
0e71485ea9
Update Rust crate regex to v1.10.6 ( #12667 )
2024-08-04 22:10:40 -04:00
renovate[bot]
43a9d282f7
Update Rust crate ordermap to v0.5.1 ( #12665 )
2024-08-04 22:10:32 -04:00
renovate[bot]
6f357b8b45
Update Rust crate tempfile to v3.11.0 ( #12671 )
2024-08-05 02:08:20 +00:00
renovate[bot]
56d985a972
Update Rust crate toml to v0.8.19 ( #12669 )
2024-08-04 22:07:44 -04:00
renovate[bot]
b3e0655cc9
Update Rust crate serde_json to v1.0.122 ( #12668 )
2024-08-04 22:07:35 -04:00
renovate[bot]
06baffec9e
Update Rust crate clap to v4.5.13 ( #12664 )
2024-08-04 22:07:26 -04:00
Micha Reiser
341a25eec1
Fix file watching on macOS if a module-search path is a symlink ( #12634 )
2024-08-03 07:24:07 +00:00
Micha Reiser
12177a42e3
Set durabilities for low-durability fields on high-durability inputs ( #12627 )
2024-08-02 19:42:34 +02:00
Micha Reiser
da824ba316
Release Ruff 0.5.6 ( #12629 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com >
2024-08-02 17:35:14 +02: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
adc8d4e1e7
File watch events: Add dynamic wait period before writing new changes ( #12585 )
2024-07-30 19:18:43 +02:00
Alex Waygood
aaa56eb0bd
Fix NFKC normalization bug when removing unused imports ( #12571 )
2024-07-30 09:54:35 +00:00
Micha Reiser
a2286c8e47
Set Durability to 'HIGH' for most inputs and third-party libraries ( #12566 )
2024-07-30 09:03:59 +00:00
Micha Reiser
2f54d05d97
Remove salsa::report_untracked_read when finding the dynamic module resolution paths ( #12509 )
2024-07-29 09:31:29 +00:00
Micha Reiser
e18b4e42d3
[red-knot] Upgrade to the *new* *new* salsa ( #12406 )
2024-07-29 07:21:24 +00:00
renovate[bot]
87d09f77cd
Update Rust crate imperative to v1.0.6 ( #12552 )
2024-07-28 22:17:28 -04:00
renovate[bot]
bd37ef13b8
Update Rust crate bstr to v1.10.0 ( #12557 )
2024-07-28 22:17:11 -04:00
renovate[bot]
ec23c974db
Update Rust crate toml to v0.8.16 ( #12554 )
2024-07-28 22:17:01 -04:00
renovate[bot]
122e5ab428
Update Rust crate serde_json to v1.0.121 ( #12553 )
2024-07-28 22:16:55 -04:00
renovate[bot]
2f2149aca8
Update Rust crate env_logger to v0.11.5 ( #12550 )
2024-07-28 22:16:49 -04:00
renovate[bot]
9d5c31e7da
Update Rust crate imara-diff to v0.1.7 ( #12551 )
2024-07-28 22:16:42 -04:00
renovate[bot]
25f3ad6238
Update Rust crate clap to v4.5.11 ( #12549 )
2024-07-28 22:16:36 -04:00
renovate[bot]
79926329a4
Update Rust crate argfile to v0.2.1 ( #12548 )
2024-07-28 22:16:31 -04:00
Charlie Marsh
d930052de8
Move required import parsing out of lint rule ( #12536 )
...
## Summary
Instead, make it part of the serialization and deserialization itself.
This makes it _much_ easier to reuse when solving
https://github.com/astral-sh/ruff/issues/12458 .
2024-07-26 13:35:45 -04:00
Micha Reiser
71f7aa4971
Remove criterion/codspeed compat layer ( #12524 )
2024-07-26 12:22:16 +02:00
Dhruv Manilawala
fc16d8d04d
Bump version to 0.5.5 ( #12510 )
2024-07-25 20:17:01 +05:30
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
Carl Meyer
f22c8ab811
[red-knot] add maybe-undefined lint rule ( #12414 )
...
Add a lint rule to detect if a name is definitely or possibly undefined
at a given usage.
If I create the file `undef/main.py` with contents:
```python
x = int
def foo():
z
return x
if flag:
y = x
y
```
And then run `cargo run --bin red_knot -- --current-directory
../ruff-examples/undef`, I get the output:
```
Name 'z' used when not defined.
Name 'flag' used when not defined.
Name 'y' used when possibly not defined.
```
If I modify the file to add `y = 0` at the top, red-knot re-checks it
and I get the new output:
```
Name 'z' used when not defined.
Name 'flag' used when not defined.
```
Note that `int` is not flagged, since it's a builtin, and `return x` in
the function scope is not flagged, since it refers to the global `x`.
2024-07-22 13:53:59 -07:00
renovate[bot]
d70ceb6a56
Update Rust crate uuid to v1.10.0 ( #12444 )
2024-07-21 21:50:53 -04:00
renovate[bot]
fc7d9e95b8
Update Rust crate tracing-tree to 0.4.0 ( #12443 )
2024-07-21 21:50:46 -04:00
renovate[bot]
fa5c841154
Update Rust crate thiserror to v1.0.63 ( #12437 )
2024-07-21 21:49:42 -04:00
renovate[bot]
97fdd48208
Update Rust crate toml to v0.8.15 ( #12438 )
2024-07-21 21:49:23 -04:00
renovate[bot]
731ed2e40b
Update Rust crate syn to v2.0.72 ( #12436 )
2024-07-21 21:49:16 -04:00
Charlie Marsh
3664f85f45
Bump version to v0.5.4 ( #12423 )
2024-07-20 17:28:13 +00:00
Dhruv Manilawala
8cfbac71a4
Bump version to 0.5.3 ( #12381 )
2024-07-18 16:07:34 +00:00
Micha Reiser
91338ae902
[red-knot] Add basic workspace support ( #12318 )
2024-07-17 11:34:21 +02:00
Micha Reiser
0c72577b5d
[red-knot] Add notebook support ( #12338 )
2024-07-17 08:26:33 +00:00
Matthew Runyon
fe04f2b09d
Publish wasm API to npm ( #12317 )
2024-07-17 08:50:38 +02:00