From bd57999c27184bf2da6960057985f1c3799501a9 Mon Sep 17 00:00:00 2001 From: Marcin Rudolf Date: Sun, 2 Jun 2024 21:01:32 +0200 Subject: [PATCH] skips non resolvable fields from appearing in sample secrets.toml, tests if dataset_name is gone --- dlt/cli/config_toml_writer.py | 7 ++++--- tests/cli/test_init_command.py | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dlt/cli/config_toml_writer.py b/dlt/cli/config_toml_writer.py index 7ff7f735eb..8a549a60ff 100644 --- a/dlt/cli/config_toml_writer.py +++ b/dlt/cli/config_toml_writer.py @@ -4,6 +4,7 @@ from tomlkit.container import Container as TOMLContainer from collections.abc import Sequence as C_Sequence +from dlt.common.configuration.specs.base_configuration import is_hint_not_resolved from dlt.common.pendulum import pendulum from dlt.common.configuration.specs import ( BaseConfiguration, @@ -11,7 +12,7 @@ extract_inner_hint, ) from dlt.common.data_types import py_type_to_sc_type -from dlt.common.typing import AnyType, is_final_type, is_optional_type +from dlt.common.typing import AnyType, is_optional_type class WritableConfigValue(NamedTuple): @@ -62,9 +63,9 @@ def write_value( # skip if table contains the name already if name in toml_table and not overwrite_existing: return - # do not dump final and optional fields if they are not of special interest + # do not dump nor resolvable and optional fields if they are not of special interest if ( - is_final_type(hint) or is_optional_type(hint) or default_value is not None + is_hint_not_resolved(hint) or is_optional_type(hint) or default_value is not None ) and not is_default_of_interest: return # get the inner hint to generate cool examples diff --git a/tests/cli/test_init_command.py b/tests/cli/test_init_command.py index 3d9fd0909f..03eded9da0 100644 --- a/tests/cli/test_init_command.py +++ b/tests/cli/test_init_command.py @@ -572,7 +572,13 @@ def assert_common_files( # destination is there assert secrets.get_value(destination_name, type, None, "destination") is not None # certain values are never there - for not_there in ["destination_name", "default_schema_name", "as_staging", "staging_config"]: + for not_there in [ + "destination_name", + "default_schema_name", + "as_staging", + "staging_config", + "dataset_name", + ]: assert secrets.get_value(not_there, type, None, "destination", destination_name)[0] is None return visitor, secrets