Skip to content

Commit 27a8964

Browse files
committed
Refactor to consistently use resolved cwd
1 parent f2a94d4 commit 27a8964

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ruff/src/resolve.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ pub fn resolve(
2424
let Ok(cwd) = std::env::current_dir() else {
2525
bail!("Working directory does not exist")
2626
};
27+
let cwd = cwd.parse_dot()?;
28+
2729
// First priority: if we're running in isolated mode, use the default settings.
2830
if config_arguments.isolated {
2931
let config = config_arguments.transform(Configuration::default());
30-
let settings = config.into_settings(&cwd.parse_dot()?)?;
32+
let settings = config.into_settings(&cwd)?;
3133
debug!("Isolated mode, not reading any pyproject.toml");
3234
return Ok(PyprojectConfig::new(
3335
PyprojectDiscoveryStrategy::Fixed,
@@ -62,7 +64,7 @@ pub fn resolve(
6264
// the "closest" `pyproject.toml` file for every Python file later on,
6365
// so these act as the "default" settings.)
6466
if let Some(pyproject) =
65-
pyproject::find_settings_toml(stdin_filename.as_ref().unwrap_or(&cwd.as_path()))?
67+
pyproject::find_settings_toml(stdin_filename.as_ref().unwrap_or(&cwd.as_ref()))?
6668
{
6769
debug!(
6870
"Using configuration file (via parent) at: {}",
@@ -132,13 +134,13 @@ pub fn resolve(
132134
// However, there may be a `pyproject.toml` with a `requires-python`
133135
// specified, and that is what we look for in this step.
134136
let fallback =
135-
find_fallback_target_version(stdin_filename.as_ref().unwrap_or(&cwd.as_path()));
137+
find_fallback_target_version(stdin_filename.as_ref().unwrap_or(&cwd.as_ref()));
136138
if let Some(version) = fallback {
137139
debug!("Derived `target-version` from found `requires-python`: {version:?}");
138140
}
139141
config.target_version = fallback.map(ast::PythonVersion::from);
140142
}
141-
let settings = config.into_settings(&cwd.parse_dot()?)?;
143+
let settings = config.into_settings(&cwd)?;
142144
Ok(PyprojectConfig::new(
143145
PyprojectDiscoveryStrategy::Hierarchical,
144146
settings,

0 commit comments

Comments
 (0)