1717from gettext import gettext as _
1818from io import StringIO
1919from pathlib import Path
20- from shutil import which
2120from types import TracebackType
2221
2322from ._compat import _default_text_stdout
@@ -235,8 +234,6 @@ def format_progress_line(self) -> str:
235234 ).rstrip ()
236235
237236 def render_progress (self ) -> None :
238- import shutil
239-
240237 if self .hidden :
241238 return
242239
@@ -250,6 +247,8 @@ def render_progress(self) -> None:
250247 buf = []
251248 # Update width in case the terminal has been resized
252249 if self .autowidth :
250+ import shutil
251+
253252 old_width = self .width
254253 self .width = 0
255254 clutter_length = term_len (self .format_progress_line ())
@@ -421,10 +420,13 @@ def _pipepager(
421420 # Split the command into the invoked CLI and its parameters.
422421 if not cmd_parts :
423422 return False
423+
424+ import shutil
425+
424426 cmd = cmd_parts [0 ]
425427 cmd_params = cmd_parts [1 :]
426428
427- cmd_filepath = which (cmd )
429+ cmd_filepath = shutil . which (cmd )
428430 if not cmd_filepath :
429431 return False
430432 # Resolves symlinks and produces a normalized absolute path string.
@@ -510,9 +512,12 @@ def _tempfilepager(
510512 # Split the command into the invoked CLI and its parameters.
511513 if not cmd_parts :
512514 return False
515+
516+ import shutil
517+
513518 cmd = cmd_parts [0 ]
514519
515- cmd_filepath = which (cmd )
520+ cmd_filepath = shutil . which (cmd )
516521 if not cmd_filepath :
517522 return False
518523 # Resolves symlinks and produces a normalized absolute path string.
@@ -573,6 +578,9 @@ def get_editor(self) -> str:
573578 return rv
574579 if WIN :
575580 return "notepad"
581+
582+ from shutil import which
583+
576584 for editor in "sensible-editor" , "vim" , "nano" :
577585 if which (editor ) is not None :
578586 return editor
0 commit comments