Skip to content

Commit

Permalink
fix: Ensure the required global folder tap settings are merged into t…
Browse files Browse the repository at this point in the history
…he concrete implementation settings
  • Loading branch information
edgarrmondragon committed Nov 30, 2024
1 parent 7fd95e3 commit ed03f81
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
15 changes: 11 additions & 4 deletions singer_sdk/contrib/filesystem/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class FolderTap(Tap, t.Generic[_T]):
This should be a subclass of `FileStream`.
"""

dynamic_catalog: bool = True

config_jsonschema: t.ClassVar[dict] = {"properties": {}}

@classmethod
Expand All @@ -124,11 +126,16 @@ def append_builtin_config(cls: type[FolderTap], config_jsonschema: dict) -> None
config_jsonschema: [description]
"""

def _merge_missing(source_jsonschema: dict, target_jsonschema: dict) -> None:
def _merge_missing(src: dict, tgt: dict) -> None:
# Append any missing properties in the target with those from source.
for k, v in source_jsonschema["properties"].items():
if k not in target_jsonschema["properties"]:
target_jsonschema["properties"][k] = v
for k, v in src["properties"].items():
if k not in tgt["properties"]:
tgt["properties"][k] = v

# Merge the required fields
source_required = src.get("required", [])
target_required = tgt.get("required", [])
tgt["required"] = list(set(source_required + target_required))

_merge_missing(BASE_CONFIG_SCHEMA, config_jsonschema)

Expand Down
13 changes: 6 additions & 7 deletions singer_sdk/plugin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ def __init__(
validate_config: True to require validation of config settings.
Raises:
ValueError: If config is not a dict or path string.
TypeError: If config is not a dict or path string.
"""
if not config:
config_dict = {}
elif isinstance(config, (str, PurePath)):
config = config or {}
if isinstance(config, (str, PurePath)):
config_dict = read_json_file(config)
warnings.warn(
"Passsing a config file path is deprecated. Please pass the config "
"Passing a config file path is deprecated. Please pass the config "
"as a dictionary instead.",
SingerSDKDeprecationWarning,
stacklevel=2,
Expand All @@ -179,7 +178,7 @@ def __init__(
# list will override those of earlier ones.
config_dict.update(read_json_file(config_path))
warnings.warn(
"Passsing a list of config file paths is deprecated. Please pass the "
"Passing a list of config file paths is deprecated. Please pass the "
"config as a dictionary instead.",
SingerSDKDeprecationWarning,
stacklevel=2,
Expand All @@ -188,7 +187,7 @@ def __init__(
config_dict = config
else:
msg = f"Error parsing config of type '{type(config).__name__}'." # type: ignore[unreachable]
raise ValueError(msg)
raise TypeError(msg)
if parse_env_config:
self.logger.info("Parsing env var for settings config...")
config_dict.update(self._env_var_config)
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/tap_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(
elif catalog is not None:
self._input_catalog = Catalog.from_dict(read_json_file(catalog))
warnings.warn(
"Passsing a catalog file path is deprecated. Please pass the catalog "
"Passing a catalog file path is deprecated. Please pass the catalog "
"as a dictionary or Catalog object instead.",
SingerSDKDeprecationWarning,
stacklevel=2,
Expand All @@ -123,7 +123,7 @@ def __init__(
elif state:
state_dict = read_json_file(state)
warnings.warn(
"Passsing a state file path is deprecated. Please pass the state "
"Passing a state file path is deprecated. Please pass the state "
"as a dictionary instead.",
SingerSDKDeprecationWarning,
stacklevel=2,
Expand Down

0 comments on commit ed03f81

Please sign in to comment.