File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
data_pipelines_cli/cli_commands Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 11import pathlib
22import tempfile
33from configparser import ConfigParser
4- from typing import List
4+ from typing import Any , List
55
66import click
77import yaml
@@ -48,13 +48,27 @@ def _get_source_tests_paths() -> List[pathlib.Path]:
4848 return list (map (lambda dir_name : pathlib .Path .cwd ().joinpath (dir_name ), dir_names ))
4949
5050
51+ def _insert_into_config_section (config : ConfigParser , section : str , key : str , value : Any ) -> None :
52+ if section not in config :
53+ config [section ] = {}
54+ config [section ][key ] = value
55+
56+
5157def _create_temporary_sqlfluff_config (env : str ) -> ConfigParser :
58+ sqlfluff_config_path = pathlib .Path .cwd ().joinpath (".sqlfluff" )
5259 config = ConfigParser ()
53- config ["sqlfluff" ] = {"templater" : "dbt" }
54- config ["sqlfluff:templater:dbt" ] = {
55- "profiles_dir" : str (generate_profiles_yml (env , copy_config_dir = True ).absolute ())
56- }
60+ if sqlfluff_config_path .exists ():
61+ config .read (sqlfluff_config_path )
62+
63+ _insert_into_config_section (config , "sqlfluff" , "templater" , "dbt" )
64+ _insert_into_config_section (
65+ config ,
66+ "sqlfluff:templater:dbt" ,
67+ "profiles_dir" ,
68+ str (generate_profiles_yml (env , copy_config_dir = True ).absolute ()),
69+ )
5770 config ["sqlfluff:templater:dbt:context" ] = read_dbt_vars_from_configs (env )
71+
5872 return config
5973
6074
You can’t perform that action at this time.
0 commit comments