Skip to content

Commit 01f0a29

Browse files
connernilsenmeta-codesync[bot]
authored andcommitted
Fix parent parent directory used in workspace config configurer
Summary: We've been passing the grandparent directory of the file we're loading instead of the parent directory for a while. Luckily, this doesn't change too much (just the workspace we might find), but we shouldn't be doing this Reviewed By: kinto0 Differential Revision: D85456687 fbshipit-source-id: 4fc44354f5aaba47ea89c0d67c6e0ff6b582763b
1 parent 13653e5 commit 01f0a29

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pyrefly/lib/commands/config_finder.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn standard_config_finder(configure: Arc<dyn ConfigConfigurer>) -> ConfigFin
181181
// We couldn't walk up and find a possible root of the project, so let's try to create a search
182182
// path that is still useful for this import by including all of its parents.
183183
None => {
184-
let path = match path.details() {
184+
let parent = match path.details() {
185185
ModulePathDetails::FileSystem(x) | ModulePathDetails::Memory(x) => {
186186
if let Some(path) = x.parent() {
187187
path
@@ -199,24 +199,21 @@ pub fn standard_config_finder(configure: Arc<dyn ConfigConfigurer>) -> ConfigFin
199199
};
200200
cache_parents
201201
.lock()
202-
.entry(path.to_owned())
202+
.entry(parent.to_owned())
203203
.or_insert_with(|| {
204204
let mut config = ConfigFile {
205205
project_includes: ConfigFile::default_project_includes(),
206206
// We use `fallback_search_path` because otherwise a user with `/sys` on their
207207
// computer (all of them) will override `sys.version` in preference to typeshed.
208-
fallback_search_path: path
208+
fallback_search_path: parent
209209
.ancestors()
210210
.map(|x| x.to_owned())
211211
.collect::<Vec<_>>(),
212212
root: ConfigBase::default_for_ide_without_config(),
213213
..Default::default()
214214
};
215-
let parent = path.parent();
216-
if let Some(parent) = parent {
217-
config.rewrite_with_path_to_config(parent);
218-
}
219-
let (config, errors) = configure2.configure(parent, config, vec![]);
215+
config.rewrite_with_path_to_config(parent);
216+
let (config, errors) = configure2.configure(Some(parent), config, vec![]);
220217
// Since this is a config we generated, these are likely internal errors.
221218
debug_log(errors);
222219
config
@@ -388,7 +385,7 @@ mod tests {
388385

389386
// check namespace
390387
let config_file = finder(
391-
Some(&root.join("no_config")),
388+
Some(&root.join("no_config/foo")),
392389
ModuleName::unknown(),
393390
ModulePath::namespace(root.join("no_config/foo")),
394391
);
@@ -404,7 +401,7 @@ mod tests {
404401

405402
// check filesystem/memory
406403
let config_file = finder(
407-
Some(&root.join("no_config")),
404+
Some(&root.join("no_config/foo")),
408405
ModuleName::unknown(),
409406
ModulePath::filesystem(root.join("no_config/foo/bar.py")),
410407
);

0 commit comments

Comments
 (0)