Micha Reiser
1ca14e4335
Move collection of parse errors to `check_file` ( #13059 )
2024-08-23 08:22:12 +02:00
Dylan
2edd32aa31
[red-knot] `SemanticIndexBuilder` visits value before target in named expressions ( #13053 )
...
The `SemanticIndexBuilder` was causing a cycle in a salsa query by
attempting to resolve the target before the value in a named expression
(e.g. `x := x+1`). This PR swaps the order, avoiding a panic.
Closes #13012 .
2024-08-22 07:59:13 -07:00
Micha Reiser
dce87c21fd
Eagerly validate typeshed versions ( #12786 )
2024-08-21 15:49:53 +00:00
Micha Reiser
5c5dfc11f0
Upgrade to Salsa with tables ( #13016 )
2024-08-21 06:58:53 +00:00
Alex Waygood
37a60460ed
[red-knot] Improve various tracing logs ( #13015 )
2024-08-20 18:34:51 +00:00
Micha Reiser
c65e3310d5
Add API to emit type-checking diagnostics ( #12988 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-08-20 07:22:30 +00:00
Micha Reiser
38c19fb96e
Fix re-entrance deadlock in Package::files ( #12948 )
2024-08-20 06:51:08 +00:00
Alex Waygood
e6d5a7af37
Add the `testing` feature of `ruff_db` as a dev-dependency for `ruff_workspace` ( #12985 )
2024-08-19 10:22:01 +00:00
Micha Reiser
dd0a7ec73e
Pull all types in corpus tests ( #12919 )
2024-08-17 11:59:55 +00:00
Alex Waygood
a9847af6e8
[red-knot] Use `Unknown` rather than `Unbound` for unresolved imports ( #12932 )
2024-08-16 20:10:33 +01:00
Dhruv Manilawala
4b9ddc4a06
[red-knot] Use Windows specific path separator in tests ( #12847 )
2024-08-12 22:26:59 +05:30
Dhruv Manilawala
99dc208b00
[red-knot] Add filename and source location for diagnostics ( #12842 )
...
## Summary
I'm not sure if this is useful but this is a hacky implementation to add
the filename and row / column numbers to the current Red Knot
diagnostics.
2024-08-12 15:56:30 +00:00
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
Micha Reiser
fabf19fdc9
Skip checking a file if it failed to read ( #12755 )
2024-08-12 07:26:37 +00:00
Alex Waygood
cf1a57df5a
Remove `red_knot_python_semantic::python_version::TargetVersion` ( #12790 )
2024-08-10 14:28:31 +01: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
Micha Reiser
ffaa35eafe
Add test helper to setup tracing ( #12741 )
2024-08-09 07:04:04 +00:00
Alex Waygood
f1de08c2a0
[red-knot] Merge the semantic and module-resolver crates ( #12751 )
2024-08-08 15:34:11 +01:00
Micha Reiser
2daa914334
Gracefully handle errors in CLI ( #12747 )
2024-08-08 11:02:47 +00:00
Micha Reiser
dc6aafecc2
Setup tracing and document tracing usage ( #12730 )
2024-08-08 06:28:40 +00:00
Alex Waygood
f34b9a77f0
[red-knot] Cleanups to logic resolving `site-packages` from a venv path ( #12731 )
2024-08-07 15:48:15 +01:00
Alex Waygood
aae9619d3d
[red-knot] Fix build on Windows ( #12719 )
...
## Summary
Tests are failing on `main` because automerge landed
https://github.com/astral-sh/ruff/pull/12716 despite the Windows tests
failing.
2024-08-06 20:21:25 +01: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
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
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
dfb08856eb
Fix file watcher stop data race ( #12626 )
2024-08-02 19:02:49 +02: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