55
66from subprocess import CalledProcessError
77from typing import TYPE_CHECKING
8- from typing import cast
98
109from poetry_plugin_bundle .bundlers .bundler import Bundler
1110
1413 from pathlib import Path
1514
1615 from cleo .io .io import IO
17- from poetry .core .semver .version import Version
16+ from cleo .io .outputs .section_output import SectionOutput
17+ from poetry .core .constraints .version import Version
1818 from poetry .poetry import Poetry
1919
2020
@@ -52,10 +52,10 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
5252 from tempfile import TemporaryDirectory
5353
5454 from cleo .io .null_io import NullIO
55+ from poetry .core .constraints .version import Version
5556 from poetry .core .masonry .builders .wheel import WheelBuilder
5657 from poetry .core .masonry .utils .module import ModuleOrPackageNotFound
5758 from poetry .core .packages .package import Package
58- from poetry .core .semver .version import Version
5959 from poetry .installation .installer import Installer
6060 from poetry .installation .operations .install import Install
6161 from poetry .utils .env import EnvManager
@@ -74,7 +74,7 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
7474
7575 message = self ._get_message (poetry , self ._path )
7676 if io .is_decorated () and not io .is_debug ():
77- io = io .section ()
77+ io = io .section () # type: ignore[assignment]
7878
7979 io .write_line (message )
8080
@@ -134,7 +134,10 @@ def bundle(self, poetry: Poetry, io: IO) -> bool:
134134 if self ._activated_groups is not None :
135135 installer .only_groups (self ._activated_groups )
136136 installer .requires_synchronization ()
137- installer .use_executor (poetry .config .get ("experimental.new-installer" , False ))
137+ use_executor = poetry .config .get ("experimental.new-installer" , False )
138+ if not use_executor :
139+ # only set if false because the method is deprecated
140+ installer .use_executor (False )
138141
139142 return_code = installer .run ()
140143 if return_code :
@@ -202,19 +205,17 @@ def _get_message(
202205 f" (<b>{ poetry .package .pretty_version } </b>) into <c2>{ path } </c2>"
203206 )
204207
205- def _write (self , io : IO , message : str ) -> None :
208+ def _write (self , io : IO | SectionOutput , message : str ) -> None :
206209 from cleo .io .outputs .section_output import SectionOutput
207210
208211 if io .is_debug () or not io .is_decorated () or not isinstance (io , SectionOutput ):
209212 io .write_line (message )
210213 return
211214
212- io = cast (SectionOutput , io )
213215 io .overwrite (message )
214216
215217 def _get_executable_info (self , executable : str ) -> tuple [str , Version ]:
216- from poetry .core .semver .version import Version
217- from poetry .utils ._compat import list_to_shell_command
218+ from poetry .core .constraints .version import Version
218219
219220 try :
220221 python_version = Version .parse (executable )
@@ -227,17 +228,14 @@ def _get_executable_info(self, executable: str) -> tuple[str, Version]:
227228
228229 try :
229230 python_version_str = subprocess .check_output (
230- list_to_shell_command (
231- [
232- executable ,
233- "-c" ,
234- (
235- "\" import sys; print('.'.join([str(s) for s in"
236- ' sys.version_info[:3]]))"'
237- ),
238- ]
239- ),
240- shell = True ,
231+ [
232+ executable ,
233+ "-c" ,
234+ (
235+ "import sys; print('.'.join([str(s) for s in"
236+ " sys.version_info[:3]]))"
237+ ),
238+ ]
241239 ).decode ()
242240 except CalledProcessError as e :
243241 from poetry .utils .env import EnvCommandError
0 commit comments