@@ -1212,14 +1212,14 @@ enum ProjectEnvironment {
12121212 /// requirements. A new environment would've been created, but `--dry-run` mode is enabled; as
12131213 /// such, a temporary environment was created instead.
12141214 WouldReplace (
1215- # [ allow ( dead_code ) ] PathBuf ,
1215+ PathBuf ,
12161216 PythonEnvironment ,
12171217 #[ allow( unused) ] tempfile:: TempDir ,
12181218 ) ,
12191219 /// A new [`PythonEnvironment`] would've been created, but `--dry-run` mode is enabled; as such,
12201220 /// a temporary environment was created instead.
12211221 WouldCreate (
1222- # [ allow ( dead_code ) ] PathBuf ,
1222+ PathBuf ,
12231223 PythonEnvironment ,
12241224 #[ allow( unused) ] tempfile:: TempDir ,
12251225 ) ,
@@ -1406,6 +1406,14 @@ impl ProjectEnvironment {
14061406 Self :: WouldCreate ( ..) => Err ( ProjectError :: DroppedEnvironment ) ,
14071407 }
14081408 }
1409+
1410+ /// Return the path to the actual target, if this was a dry run environment.
1411+ pub ( crate ) fn dry_run_target ( & self ) -> Option < & Path > {
1412+ match self {
1413+ Self :: WouldReplace ( path, _, _) | Self :: WouldCreate ( path, _, _) => Some ( path) ,
1414+ Self :: Created ( _) | Self :: Existing ( _) | Self :: Replaced ( _) => None ,
1415+ }
1416+ }
14091417}
14101418
14111419impl std:: ops:: Deref for ProjectEnvironment {
@@ -1436,14 +1444,14 @@ enum ScriptEnvironment {
14361444 /// requirements. A new environment would've been created, but `--dry-run` mode is enabled; as
14371445 /// such, a temporary environment was created instead.
14381446 WouldReplace (
1439- # [ allow ( dead_code ) ] PathBuf ,
1447+ PathBuf ,
14401448 PythonEnvironment ,
14411449 #[ allow( unused) ] tempfile:: TempDir ,
14421450 ) ,
14431451 /// A new [`PythonEnvironment`] would've been created, but `--dry-run` mode is enabled; as such,
14441452 /// a temporary environment was created instead.
14451453 WouldCreate (
1446- # [ allow ( dead_code ) ] PathBuf ,
1454+ PathBuf ,
14471455 PythonEnvironment ,
14481456 #[ allow( unused) ] tempfile:: TempDir ,
14491457 ) ,
@@ -1586,6 +1594,14 @@ impl ScriptEnvironment {
15861594 Self :: WouldCreate ( ..) => Err ( ProjectError :: DroppedEnvironment ) ,
15871595 }
15881596 }
1597+
1598+ /// Return the path to the actual target, if this was a dry run environment.
1599+ pub ( crate ) fn dry_run_target ( & self ) -> Option < & Path > {
1600+ match self {
1601+ Self :: WouldReplace ( path, _, _) | Self :: WouldCreate ( path, _, _) => Some ( path) ,
1602+ Self :: Created ( _) | Self :: Existing ( _) | Self :: Replaced ( _) => None ,
1603+ }
1604+ }
15891605}
15901606
15911607impl std:: ops:: Deref for ScriptEnvironment {
0 commit comments