@@ -66,7 +66,7 @@ fn verify_validity_of_discovered_envs() {
6666 use pet:: { find:: find_and_report_envs, locators:: create_locators} ;
6767 use pet_conda:: Conda ;
6868 use pet_core:: { os_environment:: EnvironmentApi , Configuration } ;
69- use std:: { env, sync:: Arc , thread } ;
69+ use std:: { env, sync:: Arc } ;
7070
7171 setup ( ) ;
7272
@@ -75,8 +75,10 @@ fn verify_validity_of_discovered_envs() {
7575 let environment = EnvironmentApi :: new ( ) ;
7676 let conda_locator = Arc :: new ( Conda :: from ( & environment) ) ;
7777 let poetry_locator = Arc :: new ( Poetry :: from ( & environment) ) ;
78- let mut config = Configuration :: default ( ) ;
79- config. workspace_directories = Some ( vec ! [ workspace_dir. clone( ) ] ) ;
78+ let config = Configuration {
79+ workspace_directories : Some ( vec ! [ workspace_dir. clone( ) ] ) ,
80+ ..Default :: default ( )
81+ } ;
8082 let locators = create_locators ( conda_locator. clone ( ) , poetry_locator. clone ( ) , & environment) ;
8183 for locator in locators. iter ( ) {
8284 locator. configure ( & config) ;
@@ -205,7 +207,7 @@ fn check_if_pipenv_exists() {
205207 env. kind == Some ( PythonEnvironmentKind :: Pipenv )
206208 && env. project == Some ( workspace_dir. clone ( ) )
207209 } )
208- . expect ( format ! ( "Pipenv environment not found, found {environments:?}" ) . as_str ( ) ) ;
210+ . unwrap_or_else ( || panic ! ( "Pipenv environment not found, found {environments:?}" ) ) ;
209211}
210212
211213#[ cfg( unix) ]
@@ -367,10 +369,7 @@ fn verify_we_can_get_same_env_info_using_from_with_exe(
367369 let env = PythonEnv :: new ( executable. clone ( ) , None , None ) ;
368370 let resolved =
369371 identify_python_environment_using_locators ( & env, & locators, & global_env_search_paths)
370- . expect (
371- format ! ( "Failed to resolve environment using `resolve` for {environment:?}" )
372- . as_str ( ) ,
373- ) ;
372+ . unwrap_or_else ( || panic ! ( "Failed to resolve environment using `resolve` for {environment:?}" ) ) ;
374373 trace ! (
375374 "For exe {:?} we got Environment = {:?}, To compare against {:?}" ,
376375 executable,
@@ -603,8 +602,10 @@ fn verify_we_can_get_same_env_info_using_resolve_with_exe(
603602 let os_environment = EnvironmentApi :: new ( ) ;
604603 let conda_locator = Arc :: new ( Conda :: from ( & os_environment) ) ;
605604 let poetry_locator = Arc :: new ( Poetry :: from ( & os_environment) ) ;
606- let mut config = Configuration :: default ( ) ;
607- config. workspace_directories = Some ( vec ! [ workspace_dir. clone( ) ] ) ;
605+ let config = Configuration {
606+ workspace_directories : Some ( vec ! [ workspace_dir. clone( ) ] ) ,
607+ ..Default :: default ( )
608+ } ;
608609 let locators = create_locators (
609610 conda_locator. clone ( ) ,
610611 poetry_locator. clone ( ) ,
@@ -614,9 +615,8 @@ fn verify_we_can_get_same_env_info_using_resolve_with_exe(
614615 locator. configure ( & config) ;
615616 }
616617
617- let env = resolve_environment ( & executable, & locators, & os_environment) . expect (
618- format ! ( "Failed to resolve environment using `resolve` for {environment:?}" ) . as_str ( ) ,
619- ) ;
618+ let env = resolve_environment ( executable, & locators, & os_environment)
619+ . unwrap_or_else ( || panic ! ( "Failed to resolve environment using `resolve` for {environment:?}" ) ) ;
620620 trace ! (
621621 "For exe {:?} we got Environment = {:?}, To compare against {:?}" ,
622622 executable,
@@ -724,21 +724,21 @@ fn get_python_run_command(env: &PythonEnvironment) -> Vec<String> {
724724 None => get_conda_exe ( ) . to_string ( ) ,
725725 } ;
726726 if let Some ( name) = env. name . clone ( ) {
727- return vec ! [
727+ vec ! [
728728 conda_exe,
729729 "run" . to_string( ) ,
730730 "-n" . to_string( ) ,
731731 name,
732732 "python" . to_string( ) ,
733- ] ;
733+ ]
734734 } else if let Some ( prefix) = env. prefix . clone ( ) {
735- return vec ! [
735+ vec ! [
736736 conda_exe,
737737 "run" . to_string( ) ,
738738 "-p" . to_string( ) ,
739739 prefix. to_str( ) . unwrap_or_default( ) . to_string( ) ,
740740 "python" . to_string( ) ,
741- ] ;
741+ ]
742742 } else {
743743 panic ! ( "Conda environment without name or prefix" )
744744 }
@@ -753,8 +753,8 @@ fn get_python_run_command(env: &PythonEnvironment) -> Vec<String> {
753753 }
754754}
755755
756- fn get_python_interpreter_info ( cli : & Vec < String > ) -> InterpreterInfo {
757- let mut cli = cli. clone ( ) ;
756+ fn get_python_interpreter_info ( cli : & [ String ] ) -> InterpreterInfo {
757+ let mut cli = cli. to_owned ( ) ;
758758 cli. push (
759759 resolve_test_path ( & [ "interpreterInfo.py" ] )
760760 . to_str ( )
@@ -765,13 +765,13 @@ fn get_python_interpreter_info(cli: &Vec<String>) -> InterpreterInfo {
765765 let output = std:: process:: Command :: new ( cli. first ( ) . unwrap ( ) )
766766 . args ( & cli[ 1 ..] )
767767 . output ( )
768- . expect ( format ! ( "Failed to execute command {cli:?}" ) . as_str ( ) ) ;
768+ . unwrap_or_else ( |_| panic ! ( "Failed to execute command {cli:?}" ) ) ;
769769 let output = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
770770 trace ! ( "Get Interpreter Info: {:?} => {:?}" , cli, output) ;
771771 let output = output
772772 . split_once ( "503bebe7-c838-4cea-a1bc-0f2963bcb657" )
773773 . unwrap ( )
774774 . 1 ;
775- let info: InterpreterInfo = serde_json:: from_str ( & output) . unwrap ( ) ;
775+ let info: InterpreterInfo = serde_json:: from_str ( output) . unwrap ( ) ;
776776 info
777777}
0 commit comments