From a553c38d215491e2040387ad9c2be882a9232329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:57:08 -0600 Subject: [PATCH] refactor: Fail early if input files to `--catalog` or `--state` do not exist (#2788) --- singer_sdk/tap_base.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/singer_sdk/tap_base.py b/singer_sdk/tap_base.py index ea6f96beb..c26fb823f 100644 --- a/singer_sdk/tap_base.py +++ b/singer_sdk/tap_base.py @@ -4,6 +4,7 @@ import abc import contextlib +import pathlib import typing as t import warnings from enum import Enum @@ -494,8 +495,8 @@ def invoke( # type: ignore[override] about: bool = False, about_format: str | None = None, config: tuple[str, ...] = (), - state: str | None = None, - catalog: str | None = None, + state: pathlib.Path | None = None, + catalog: pathlib.Path | None = None, ) -> None: """Invoke the tap's command line interface. @@ -619,12 +620,20 @@ def get_singer_command(cls: type[Tap]) -> click.Command: click.Option( ["--catalog"], help="Use a Singer catalog file with the tap.", - type=click.Path(), + type=click.Path( + path_type=pathlib.Path, + exists=True, + dir_okay=False, + ), ), click.Option( ["--state"], help="Use a bookmarks file for incremental replication.", - type=click.Path(), + type=click.Path( + path_type=pathlib.Path, + exists=True, + dir_okay=False, + ), ), ], )