Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[red-knot] Remove support for resolving modules by package directory path #11162

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/red_knot/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ where

if module_path.root() == &root_path {
let normalized = path.canonicalize().ok()?;
let module_path = db.file_path(module_path.file());
let interned_normalized = db.file_id(&normalized);

if !module_path.starts_with(normalized) {
if interned_normalized != module_path.file() {
// This path is for a module with the same name but with a different precedence. For example:
// ```
// src/foo.py
Expand Down Expand Up @@ -662,8 +662,8 @@ mod tests {

assert_eq!(Some(foo_module), db.path_to_module(&foo_path));

// TODO: Should resolving by the directory name resolve a module or not?
assert_eq!(Some(foo_module), db.path_to_module(&foo_dir));
// Resolving by directory doesn't resolve to the init file.
assert_eq!(None, db.path_to_module(&foo_dir));

Ok(())
}
Expand Down
Loading