ruff/crates/ruff_server/src
Charlie Marsh c7d48e10e6
Detect empty implicit namespace packages (#14236)
## Summary

The implicit namespace package rule currently fails to detect cases like
the following:

```text
foo/
├── __init__.py
└── bar/
    └── baz/
        └── __init__.py
```

The problem is that we detect a root at `foo`, and then an independent
root at `baz`. We _would_ detect that `bar` is an implicit namespace
package, but it doesn't contain any files! So we never check it, and
have no place to raise the diagnostic.

This PR adds detection for these kinds of nested packages, and augments
the `INP` rule to flag the `__init__.py` file above with a specialized
message. As a side effect, I've introduced a dedicated `PackageRoot`
struct which we can pass around in lieu of Yet Another `Path`.

For now, I'm only enabling this in preview (and the approach doesn't
affect any other rules). It's a bug fix, but it may end up expanding the
rule.

Closes https://github.com/astral-sh/ruff/issues/13519.
2024-11-09 22:03:34 -05:00
..
edit Fix server panic when undoing an edit (#14010) 2024-11-01 08:16:53 +01:00
server Avoid indexing the workspace for single-file mode (#13770) 2024-10-18 10:51:43 +05:30
session Avoid indexing the workspace for single-file mode (#13770) 2024-10-18 10:51:43 +05:30
edit.rs Add support for extensionless Python files for server (#13326) 2024-09-12 00:35:26 +05:30
fix.rs Detect empty implicit namespace packages (#14236) 2024-11-09 22:03:34 -05:00
format.rs ruff server: Formatting a document with syntax problems no longer spams a visible error popup (#11745) 2024-06-04 17:18:21 -07:00
lib.rs Avoid indexing the workspace for single-file mode (#13770) 2024-10-18 10:51:43 +05:30
lint.rs Detect empty implicit namespace packages (#14236) 2024-11-09 22:03:34 -05:00
message.rs Ignore non-file workspace URL (#12725) 2024-08-07 09:15:55 +00:00
resolve.rs Add support for extensionless Python files for server (#13326) 2024-09-12 00:35:26 +05:30
server.rs Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
session.rs Avoid indexing the workspace for single-file mode (#13770) 2024-10-18 10:51:43 +05:30
trace.rs Use $/logTrace for server trace logs in Zed and VS Code (#12564) 2024-07-30 08:32:20 +05:30