1818import os
1919import re
2020import shlex
21- import subprocess
2221import sys
2322from dataclasses import dataclass
2423from pathlib import Path
24+ from subprocess import run as _subprocess_run
2525from typing import Dict , List , Optional , Tuple
2626
2727import yaml
@@ -58,7 +58,7 @@ def __init__(self, project_root: Path):
5858
5959 def _load_scripts (self ) -> None :
6060 """Load scripts from snowflake.yml or manifest.yml.
61-
61+
6262 Scripts can be defined in either file but not both.
6363 Raises ClickException if scripts are found in both files.
6464 """
@@ -81,15 +81,23 @@ def _load_scripts(self) -> None:
8181 self ._scripts = manifest_scripts
8282 self ._scripts_source = manifest_source
8383
84- def _load_snowflake_scripts (self ) -> Tuple [Optional [Dict [str , ScriptModel ]], Optional [str ]]:
84+ def _load_snowflake_scripts (
85+ self ,
86+ ) -> Tuple [Optional [Dict [str , ScriptModel ]], Optional [str ]]:
8587 """Load scripts from snowflake.yml via project definition."""
8688 ctx = get_cli_context ()
8789 project_def = ctx .project_definition
88- if project_def and isinstance (project_def , DefinitionV20 ) and project_def .scripts :
90+ if (
91+ project_def
92+ and isinstance (project_def , DefinitionV20 )
93+ and project_def .scripts
94+ ):
8995 return project_def .scripts , "snowflake.yml"
9096 return None , None
9197
92- def _load_manifest_scripts (self ) -> Tuple [Optional [Dict [str , ScriptModel ]], Optional [str ]]:
98+ def _load_manifest_scripts (
99+ self ,
100+ ) -> Tuple [Optional [Dict [str , ScriptModel ]], Optional [str ]]:
93101 """Load scripts from manifest.yml if present."""
94102 manifest_path = SecurePath (self .project_root / MANIFEST_FILE_NAME )
95103 if not manifest_path .exists ():
@@ -99,7 +107,7 @@ def _load_manifest_scripts(self) -> Tuple[Optional[Dict[str, ScriptModel]], Opti
99107 with manifest_path .open ("r" , read_file_limit_mb = DEFAULT_SIZE_LIMIT_MB ) as f :
100108 manifest_data = yaml .safe_load (f .read ())
101109 except Exception as e :
102- log .debug (f "Could not read manifest.yml: { e } " )
110+ log .debug ("Could not read manifest.yml: %s" , e )
103111 return None , None
104112
105113 if not manifest_data or "scripts" not in manifest_data :
@@ -216,7 +224,13 @@ def execute_script(
216224
217225 if script .run :
218226 return self ._execute_composite (
219- name , script , extra_args , var_overrides , dry_run , verbose , continue_on_error
227+ name ,
228+ script ,
229+ extra_args ,
230+ var_overrides ,
231+ dry_run ,
232+ verbose ,
233+ continue_on_error ,
220234 )
221235
222236 return self ._execute_command (
@@ -260,14 +274,14 @@ def _execute_command(
260274 )
261275
262276 if sys .platform == "win32" :
263- result = subprocess . run (
277+ result = _subprocess_run (
264278 cmd ,
265279 shell = True ,
266280 cwd = cwd ,
267281 env = env ,
268282 )
269283 else :
270- result = subprocess . run (
284+ result = _subprocess_run (
271285 cmd ,
272286 shell = True ,
273287 cwd = cwd ,
@@ -276,7 +290,7 @@ def _execute_command(
276290 )
277291 else :
278292 args = shlex .split (cmd )
279- result = subprocess . run (
293+ result = _subprocess_run (
280294 args ,
281295 cwd = cwd ,
282296 env = env ,
0 commit comments